Skip to content

Commit e08a576

Browse files
committed
docs: update content
1 parent 86dae5a commit e08a576

File tree

1 file changed

+52
-52
lines changed

1 file changed

+52
-52
lines changed

docs/content/components/offcanvas.md

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@ other_frameworks: offcanvas
1010

1111
## How it works
1212

13-
Offcanvas is a sidebar component that can be toggled via JavaScript to appear from the left, right, top, or bottom edge of the viewport. Buttons or anchors are used as triggers that are attached to specific elements you toggle, and `data` attributes are used to invoke our JavaScript.
13+
The Bootstrap Offcanvas component serves as a sidebar element that can be activated through JavaScript, allowing it to slide in from the left, right, top, or bottom of the viewport. Triggers, like buttons or anchors, are linked to the elements you want to toggle, and data attributes facilitate their activation in JavaScript.
1414

15-
- Offcanvas shares some of the same JavaScript code as modals. Conceptually, they are quite similar, but they are separate plugins.
16-
- Similarly, some [source Sass](#sass) variables for offcanvas's styles and dimensions are inherited from the modal's variables.
17-
- When shown, offcanvas includes a default backdrop that can be clicked to hide the offcanvas.
18-
- Similar to modals, only one offcanvas can be shown at a time.
15+
- Offcanvas shares some JavaScript code with modals. Conceptually, they are quite similar, but they remain separate plugins.
16+
- Likewise, some [source Sass](#sass) variables for offcanvas styles and dimensions are derived from the modal variables.
17+
- When displayed, offcanvas features a default backdrop that can be clicked to hide it.
18+
- As with modals, only one offcanvas can be displayed at a time.
1919

20-
**Heads up!** Given how CSS handles animations, you cannot use `margin` or `translate` on an `.offcanvas` element. Instead, use the class as an independent wrapping element.
20+
**Attention!** Due to CSS animation handling, `margin` or `translate` cannot be applied to an `.offcanvas` element. Instead, utilize the class as a separate wrapping element.
2121

2222
{{< callout info >}}
2323
{{< partial "callouts/info-prefersreducedmotion.md" >}}
@@ -27,7 +27,7 @@ Offcanvas is a sidebar component that can be toggled via JavaScript to appear fr
2727

2828
### Offcanvas components
2929

30-
Below is an offcanvas example that is shown by default (via `.show` on `.offcanvas`). Offcanvas includes support for a header with a close button and an optional body class for some initial `padding`. We suggest that you include offcanvas headers with dismiss actions whenever possible, or provide an explicit dismiss action.
30+
Below is a default offcanvas example (via `.show` on `.offcanvas`). Offcanvas supports a header with a close button and an optional body class for initial `padding`. We recommend including offcanvas headers with dismiss actions whenever possible, or providing an explicit dismiss action.
3131

3232
{{< example class="docs-example-offcanvas p-0 bg-light overflow-hidden" >}}
3333
<div class="offcanvas offcanvas-start show" tabindex="-1" id="offcanvas" aria-labelledby="offcanvasLabel">
@@ -36,19 +36,19 @@ Below is an offcanvas example that is shown by default (via `.show` on `.offcanv
3636
<button type="button" class="btn-close" data-coreui-dismiss="offcanvas" aria-label="Close"></button>
3737
</div>
3838
<div class="offcanvas-body">
39-
Content for the offcanvas goes here. You can place just about any Bootstrap component or custom elements here.
39+
The content for the Bootstrap offcanvas goes here. You can place nearly any Bootstrap component or custom element here.
4040
</div>
4141
</div>
4242
{{< /example >}}
4343

4444
### Live demo
4545

46-
Use the buttons below to show and hide an offcanvas element via JavaScript that toggles the `.show` class on an element with the `.offcanvas` class.
46+
Utilize the buttons below to toggle the visibility of an offcanvas element using JavaScript, which adds or removes the `.show` class from an element with the `.offcanvas` class.
4747

48-
- `.offcanvas` hides content (default)
49-
- `.offcanvas.show` shows content
48+
- `.offcanvas` hides content.
49+
- `.offcanvas.show` shows content.
5050

51-
You can use a link with the `href` attribute, or a button with the `data-coreui-target` attribute. In both cases, the `data-coreui-toggle="offcanvas"` is required.
51+
You can employ a link with the `href` attribute or a button featuring the `data-coreui-target` attribute. In both instances, including `data-coreui-toggle="offcanvas"` is necessary.
5252

5353
{{< example >}}
5454
<a class="btn btn-primary" data-coreui-toggle="offcanvas" href="#offcanvasExample" role="button" aria-controls="offcanvasExample">
@@ -65,7 +65,7 @@ You can use a link with the `href` attribute, or a button with the `data-coreui-
6565
</div>
6666
<div class="offcanvas-body">
6767
<div class="">
68-
Some text as placeholder. In real life you can have the elements you have chosen. Like, text, images, lists, etc.
68+
Some text as a placeholder. In real life, you can have the elements you have chosen, like text, images, lists, etc.
6969
</div>
7070
<div class="dropdown mt-3">
7171
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-coreui-toggle="dropdown">
@@ -83,7 +83,7 @@ You can use a link with the `href` attribute, or a button with the `data-coreui-
8383

8484
### Body scrolling
8585

86-
Scrolling the `<body>` element is disabled when an offcanvas and its backdrop are visible. Use the `data-coreui-scroll` attribute to enable `<body>` scrolling.
86+
The `<body>` element's scrolling is disabled when the Bootstrap offcanvas and its backdrop are visible. Utilize the `data-coreui-scroll` attribute to allow scrolling on the `<body>`.
8787

8888
{{< example >}}
8989
<button class="btn btn-primary" type="button" data-coreui-toggle="offcanvas" data-coreui-target="#offcanvasScrolling" aria-controls="offcanvasScrolling">Enable body scrolling</button>
@@ -94,7 +94,8 @@ Scrolling the `<body>` element is disabled when an offcanvas and its backdrop ar
9494
<button type="button" class="btn-close" data-coreui-dismiss="offcanvas" aria-label="Close"></button>
9595
</div>
9696
<div class="offcanvas-body">
97-
<p>Try scrolling the rest of the page to see this option in action.</p>
97+
<p>Scroll further down the page to see this option in action.
98+
</p>
9899
</div>
99100
</div>
100101
{{< /example >}}
@@ -119,8 +120,7 @@ You can also enable `<body>` scrolling with a visible backdrop.
119120

120121
### Static backdrop
121122

122-
When backdrop is set to static, the offcanvas will not close when clicking outside of it.
123-
123+
When the backdrop is set to static, the Bootstrap offcanvas will remain open when clicking outside of it.
124124
{{< example >}}
125125
<button class="btn btn-primary" type="button" data-coreui-toggle="offcanvas" data-coreui-target="#staticBackdrop" aria-controls="staticBackdrop">
126126
Toggle static offcanvas
@@ -133,7 +133,7 @@ When backdrop is set to static, the offcanvas will not close when clicking outsi
133133
</div>
134134
<div class="offcanvas-body">
135135
<div>
136-
I will not close if you click outside of me.
136+
I won’t close if you click outside of me.
137137
</div>
138138
</div>
139139
</div>
@@ -143,10 +143,10 @@ When backdrop is set to static, the offcanvas will not close when clicking outsi
143143

144144
{{< deprecated-in "5.0.0" >}} {{< added-in "4.2.6" >}}
145145

146-
Change the appearance of offcanvases with utilities to better match them to different contexts like dark navbars. Here we add `.text-bg-dark` to the `.offcanvas` and `.btn-close-white` to `.btn-close` for proper styling with a dark offcanvas. If you have dropdowns within, consider also adding `.dropdown-menu-dark` to `.dropdown-menu`.
146+
Change the appearance of offcanvas elements using utilities to better match various contexts, such as dark navbars. Here, we add `.text-bg-dark` to the `.offcanvas` and `.btn-close-white` to `.btn-close` for proper styling with a dark offcanvas. If there are dropdowns inside, consider also adding `.dropdown-menu-dark` to `.dropdown-menu`.
147147

148148
{{< callout warning >}}
149-
Heads up! Dark variants for components were deprecated in v5.3.0 with the introduction of color modes. Instead of manually adding classes mentioned above, set `data-coreui-theme="dark"` on the root element, a parent wrapper, or the component itself.
149+
Attention! Dark variants for components are no longer supported as of v5.3.0 due to the introduction of color modes. Instead of manually adding the classes mentioned earlier, simply set `data-coreui-theme="dark"` on the root element, a parent wrapper, or the component itself.
150150
{{< /callout >}}
151151

152152
{{< example class="docs-example-offcanvas p-0 bg-body-secondary overflow-hidden" >}}
@@ -165,7 +165,7 @@ Heads up! Dark variants for components were deprecated in v5.3.0 with the introd
165165

166166
{{< added-in "4.2.6" >}}
167167

168-
Responsive offcanvas classes hide content outside the viewport from a specified breakpoint and down. Above that breakpoint, the contents within will behave as usual. For example, `.offcanvas-lg` hides content in an offcanvas below the `lg` breakpoint, but shows the content above the `lg` breakpoint.
168+
Responsive offcanvas classes hide content that is outside the viewport from a specified breakpoint and lower. Above that breakpoint, the content will behave normally. For example, `.offcanvas-lg` hides content in an offcanvas below the `lg` breakpoint, but displays the content above the `lg` breakpoint.
169169

170170
{{< example >}}
171171
<button class="btn btn-primary d-lg-none" type="button" data-coreui-toggle="offcanvas" data-coreui-target="#offcanvasResponsive" aria-controls="offcanvasResponsive">Toggle offcanvas</button>
@@ -183,7 +183,7 @@ Responsive offcanvas classes hide content outside the viewport from a specified
183183
</div>
184184
{{< /example >}}
185185

186-
Responsive offcanvas classes are available across for each breakpoint.
186+
Responsive offcanvas classes are available for each breakpoint.
187187

188188
- `.offcanvas`
189189
- `.offcanvas-sm`
@@ -194,14 +194,14 @@ Responsive offcanvas classes are available across for each breakpoint.
194194

195195
## Placement
196196

197-
There's no default placement for offcanvas components, so you must add one of the modifier classes below.
197+
Offcanvas components do not have a default position; therefore, you need to apply one of the modifier classes listed below.
198198

199-
- `.offcanvas-start` places offcanvas on the left of the viewport (shown above)
200-
- `.offcanvas-end` places offcanvas on the right of the viewport
201-
- `.offcanvas-top` places offcanvas on the top of the viewport
202-
- `.offcanvas-bottom` places offcanvas on the bottom of the viewport
199+
- `.offcanvas-start` places the offcanvas on the left side of the viewport (as shown above)
200+
- `.offcanvas-end` places the offcanvas on the right side of the viewport
201+
- `.offcanvas-top` places offcanvas at the top of the viewport
202+
- `.offcanvas-bottom` places offcanvas at the bottom of the viewport
203203

204-
Try the top, right, and bottom examples out below.
204+
Feel free to experiment with the top, right, and bottom examples below.
205205

206206
{{< example >}}
207207
<button class="btn btn-primary" type="button" data-coreui-toggle="offcanvas" data-coreui-target="#offcanvasTop" aria-controls="offcanvasTop">Toggle top offcanvas</button>
@@ -253,27 +253,27 @@ Since the offcanvas panel is conceptually a modal dialog, be sure to add `aria-l
253253

254254
{{< bootstrap-compatibility >}}
255255

256-
The offcanvas plugin utilizes a few classes and attributes to handle the heavy lifting:
256+
The offcanvas plugin leverages several classes and attributes to perform its functions:
257257

258258
- `.offcanvas` hides the content
259259
- `.offcanvas.show` shows the content
260260
- `.offcanvas-start` hides the offcanvas on the left
261261
- `.offcanvas-end` hides the offcanvas on the right
262-
- `.offcanvas-top` hides the offcanvas on the top
263-
- `.offcanvas-bottom` hides the offcanvas on the bottom
262+
- `.offcanvas-top` hides the offcanvas at the top
263+
- `.offcanvas-bottom` hides the offcanvas at the bottom
264264

265-
Add a dismiss button with the `data-coreui-dismiss="offcanvas"` attribute, which triggers the JavaScript functionality. Be sure to use the `<button>` element with it for proper behavior across all devices.
265+
Include a dismiss button using the `data-coreui-dismiss="offcanvas"` attribute to activate the JavaScript functionality. Ensure you use the `<button>` element for consistent behavior across all devices.
266266

267267
### Via data attributes
268268

269-
Add `data-coreui-toggle="offcanvas"` and a `data-coreui-target` or `href` to the element to automatically assign control of one offcanvas element. The `data-coreui-target` attribute accepts a CSS selector to apply the offcanvas to. Be sure to add the class `offcanvas` to the offcanvas element. If you'd like it to default open, add the additional class `show`.
269+
Include `data-coreui-toggle="offcanvas"` along with a `data-coreui-target` or `href` in the element to automatically control a single offcanvas component. The `data-coreui-target` attribute allows you to specify a CSS selector for the associated offcanvas. Remember to apply the `offcanvas` class to the offcanvas element. To have it open by default, also add the `show` class.
270270

271271
#### Dismiss
272272

273273
{{% js-dismiss "offcanvas" %}}
274274

275275
{{< callout warning >}}
276-
While both ways to dismiss an offcanvas are supported, keep in mind that dismissing from outside an offcanvas does not match the [ARIA Authoring Practices Guide dialog (modal) pattern](https://www.w3.org/WAI/ARIA/apg/patterns/dialogmodal/). Do this at your own risk.
276+
While both methods for dismissing an offcanvas are supported, remember that dismissing from the outside of an offcanvas does not align with the [ARIA Authoring Practices Guide dialog (modal) pattern](https://www.w3.org/WAI/ARIA/apg/patterns/dialogmodal/). Proceed with caution.
277277
{{< /callout >}}
278278

279279
### Via JavaScript
@@ -294,9 +294,9 @@ const offcanvasList = [...offcanvasElementList].map(offcanvasEl => new coreui.Of
294294
{{< bs-table "table" >}}
295295
| Name | Type | Default | Description |
296296
| --- | --- | --- | --- |
297-
| `backdrop` | boolean or the string `static` | `true` | Apply a backdrop on body while offcanvas is open. Alternatively, specify `static` for a backdrop which doesn't close the offcanvas when clicked. |
298-
| `keyboard` | boolean | `true` | Closes the offcanvas when escape key is pressed |
299-
| `scroll` | boolean | `false` | Allow body scrolling while offcanvas is open |
297+
| `backdrop` | boolean or the string `static` | `true` | Applies a backdrop to the body while the Bootstrap offcanvas is open. Alternatively, specify `static` for a backdrop that doesn't close the offcanvas component when clicked. |
298+
| `keyboard` | boolean | `true` | Closes the offcanvas when the escape key is pressed. |
299+
| `scroll` | boolean | `false` | Allows body scrolling while the offcanvas is open.
300300
{{< /bs-table >}}
301301

302302
### Methods
@@ -305,36 +305,36 @@ const offcanvasList = [...offcanvasElementList].map(offcanvasEl => new coreui.Of
305305
{{< partial "callouts/danger-async-methods.md" >}}
306306
{{< /callout >}}
307307

308-
Activates your content as an offcanvas element. Accepts an optional options `object`.
308+
Activates your content as an offcanvas element and accepts an optional options `object`.
309309

310-
You can create an offcanvas instance with the constructor, for example:
310+
You can create an offcanvas instance using the constructor; for example:
311311

312312
```js
313-
const bsOffcanvas = new coreui.Offcanvas('#myOffcanvas')
313+
const cuiOffcanvas = new coreui.Offcanvas('#myOffcanvas')
314314
```
315315

316316
{{< bs-table "table" >}}
317317
| Method | Description |
318318
| --- | --- |
319-
| `getInstance` | *Static* method which allows you to get the offcanvas instance associated with a DOM element |
320-
| `getOrCreateInstance` | *Static* method which allows you to get the offcanvas instance associated with a DOM element, or create a new one in case it wasn't initialized |
321-
| `hide` | Hides an offcanvas element. **Returns to the caller before the offcanvas element has actually been hidden** (i.e. before the `hidden.coreui.offcanvas` event occurs).|
322-
| `show` | Shows an offcanvas element. **Returns to the caller before the offcanvas element has actually been shown** (i.e. before the `shown.coreui.offcanvas` event occurs).|
323-
| `toggle` | Toggles an offcanvas element to shown or hidden. **Returns to the caller before the offcanvas element has actually been shown or hidden** (i.e. before the `shown.coreui.offcanvas` or `hidden.coreui.offcanvas` event occurs). |
319+
| `getInstance` | *Static* method that allows you to obtain the offcanvas instance associated with a DOM element |
320+
| `getOrCreateInstance` | *Static* method that enables you to retrieve the offcanvas instance linked to a DOM element, or create a new one if it hasn't been initialized |
321+
| `hide` | Hides an offcanvas element. **Returns to the caller before the offcanvas element is actually hidden** (i.e. before the `hidden.coreui.offcanvas` event occurs).|
322+
| `show` | Displays an offcanvas element. **Returns to the caller before the offcanvas element is actually shown** (i.e. before the `shown.coreui.offcanvas` event occurs).|
323+
| `toggle` | Switches an offcanvas element between shown and hidden. **Returns to the caller before the offcanvas element is actually shown or hidden** (i.e. before the `shown.coreui.offcanvas` or `hidden.coreui.offcanvas` event occurs).
324324
{{< /bs-table >}}
325325

326326
### Events
327327

328328
CoreUI for Bootstrap's offcanvas class exposes a few events for hooking into offcanvas functionality.
329329

330330
{{< bs-table "table" >}}
331-
| Event type | Description |
331+
| Event Type | Description |
332332
| --- | --- |
333-
| `hide.coreui.offcanvas` | This event is fired immediately when the `hide` method has been called. |
334-
| `hidden.coreui.offcanvas` | This event is fired when an offcanvas element has been hidden from the user (will wait for CSS transitions to complete). |
335-
| `hidePrevented.coreui.offcanvas` | This event is fired when the offcanvas is shown, its backdrop is `static` and a click outside of the offcanvas is performed. The event is also fired when the escape key is pressed and the `keyboard` option is set to `false`. |
336-
| `show.coreui.offcanvas` | This event fires immediately when the `show` instance method is called. |
337-
| `shown.coreui.offcanvas` | This event is fired when an offcanvas element has been made visible to the user (will wait for CSS transitions to complete). |
333+
| `hide.coreui.offcanvas` | This event is fired immediately after the `hide` method has been called. |
334+
| `hidden.coreui.offcanvas` | This event is fired when an offcanvas element is hidden from the user (it will wait for CSS transitions to complete). |
335+
| `hidePrevented.coreui.offcanvas` | This event is triggered when the offcanvas is shown, its backdrop is `static`, and a click outside of the offcanvas occurs. The event is also triggered when the escape key is pressed and the `keyboard` option is set to `false`. |
336+
| `show.coreui.offcanvas` | This event fires immediately when the `show` instance method is invoked. |
337+
| `shown.coreui.offcanvas` | This event is fired when an offcanvas element becomes visible to the user (it will wait for CSS transitions to complete).
338338
{{< /bs-table >}}
339339

340340
```js
@@ -348,7 +348,7 @@ myOffcanvas.addEventListener('hidden.coreui.offcanvas', event => {
348348

349349
### CSS variables
350350

351-
Offcanvas uses local CSS variables on `.offcanvas` for enhanced real-time customization. Values for the CSS variables are set via Sass, so Sass customization is still supported, too.
351+
Offcanvas utilizes local CSS variables on `.offcanvas` for improved real-time customization. The values for the CSS variables are defined through Sass, ensuring that Sass customization remains supported as well.
352352

353353
{{< scss-docs name="offcanvas-css-vars" file="scss/_offcanvas.scss" >}}
354354

0 commit comments

Comments
 (0)