Skip to content

Commit 7bb524c

Browse files
committed
docs: update examples
1 parent eaab236 commit 7bb524c

File tree

2 files changed

+80
-21
lines changed

2 files changed

+80
-21
lines changed

packages/docs/content/components/popover.mdx

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,38 @@ Use the `focus` trigger to dismiss popovers on the user's next click of a differ
153153
</CPopover>
154154
```
155155

156+
## Usage
157+
158+
### Disabled elements
159+
160+
Elements with the disabled attribute aren't interactive, meaning users cannot hover or click them to trigger a popover (or tooltip). As a workaround, you'll want to trigger the popover from a wrapper `<div>` or `<span>`, ideally made keyboard-focusable using `tabindex="0"`.
161+
162+
For disabled popover triggers, you may also prefer `trigger={['hover', 'focus']}` so that the popover appears as immediate visual feedback to your users as they may not expect to click on a disabled element.
163+
164+
<Example>
165+
<CPopover
166+
content="Disabled popover"
167+
placement="right"
168+
trigger={['hover', 'focus']}
169+
>
170+
<span className="d-inline-block" tabIndex={0}>
171+
<CButton color="primary" disabled>Disabled button</CButton>
172+
</span>
173+
</CPopover>
174+
</Example>
175+
```jsx
176+
<CPopover
177+
content="Disabled popover"
178+
placement="right"
179+
trigger={['hover', 'focus']}
180+
>
181+
<span className="d-inline-block" tabIndex={0}>
182+
<CButton color="primary" disabled>Disabled button</CButton>
183+
</span>
184+
</CPopover>
185+
```
186+
187+
156188
## Customizing
157189

158190
### CSS variables

packages/docs/content/components/tooltip.mdx

Lines changed: 48 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -109,30 +109,57 @@ Hover over the buttons below to see the four tooltips directions: top, right, bo
109109
</Example>
110110

111111
```jsx
112+
<CTooltip
113+
content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus."
114+
placement="top"
115+
>
116+
<CButton color="secondary">Tooltip on top</CButton>
117+
</CTooltip>
118+
<CTooltip
119+
content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus."
120+
placement="right"
121+
>
122+
<CButton color="secondary">Tooltip on right</CButton>
123+
</CTooltip>
124+
<CTooltip
125+
content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus."
126+
placement="bottom"
127+
>
128+
<CButton color="secondary">Tooltip on bottom</CButton>
129+
</CTooltip>
130+
<CTooltip
131+
content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus."
132+
placement="left"
133+
>
134+
<CButton color="secondary">Tooltip on left</CButton>
135+
</CTooltip>
136+
```
137+
138+
## Usage
139+
140+
### Disabled elements
141+
142+
Elements with the disabled attribute aren’t interactive, meaning users cannot focus, hover, or click them to trigger a tooltip (or popover). As a workaround, you’ll want to trigger the tooltip from a wrapper `<div>` or `<span>`, ideally made keyboard-focusable using `tabindex="0"`.
143+
144+
<Example>
112145
<CTooltip
113-
content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus."
114-
placement="top"
115-
>
116-
<CButton color="secondary">Tooltip on top</CButton>
117-
</CTooltip>
118-
<CTooltip
119-
content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus."
120-
placement="right"
121-
>
122-
<CButton color="secondary">Tooltip on right</CButton>
123-
</CTooltip>
124-
<CTooltip
125-
content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus."
126-
placement="bottom"
127-
>
128-
<CButton color="secondary">Tooltip on bottom</CButton>
129-
</CTooltip>
130-
<CTooltip
131-
content="Vivamus sagittis lacus vel augue laoreet rutrum faucibus."
132-
placement="left"
146+
content="Disabled tooltip"
147+
trigger={['hover', 'focus']}
133148
>
134-
<CButton color="secondary">Tooltip on left</CButton>
149+
<span className="d-inline-block" tabIndex={0}>
150+
<CButton color="primary" disabled>Disabled button</CButton>
151+
</span>
135152
</CTooltip>
153+
</Example>
154+
```jsx
155+
<CTooltip
156+
content="Disabled tooltip"
157+
trigger={['hover', 'focus']}
158+
>
159+
<span className="d-inline-block" tabIndex={0}>
160+
<CButton color="primary" disabled>Disabled button</CButton>
161+
</span>
162+
</CTooltip>
136163
```
137164

138165
## Customizing

0 commit comments

Comments
 (0)