Skip to content

Commit a60e276

Browse files
committed
Merge branch 'main' of https://github.com/coreui/coreui
2 parents ea81d8f + 1a1dc94 commit a60e276

File tree

2 files changed

+56
-52
lines changed

2 files changed

+56
-52
lines changed

docs/content/components/offcanvas.md

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

1414
## How it works
1515

16-
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.
16+
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.
1717

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

23-
**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.
23+
**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.
2424

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

3131
### Offcanvas components
3232

33-
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.
33+
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.
3434

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

4747
### Live demo
4848

49-
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.
49+
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.
5050

51-
- `.offcanvas` hides content (default)
52-
- `.offcanvas.show` shows content
51+
- `.offcanvas` hides content.
52+
- `.offcanvas.show` shows content.
5353

54-
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.
54+
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.
5555

5656
{{< example >}}
5757
<a class="btn btn-primary" data-coreui-toggle="offcanvas" href="#offcanvasExample" role="button" aria-controls="offcanvasExample">
@@ -68,7 +68,7 @@ You can use a link with the `href` attribute, or a button with the `data-coreui-
6868
</div>
6969
<div class="offcanvas-body">
7070
<div class="">
71-
Some text as placeholder. In real life you can have the elements you have chosen. Like, text, images, lists, etc.
71+
Some text as a placeholder. In real life, you can have the elements you have chosen, like text, images, lists, etc.
7272
</div>
7373
<div class="dropdown mt-3">
7474
<button class="btn btn-secondary dropdown-toggle" type="button" id="dropdownMenuButton" data-coreui-toggle="dropdown">
@@ -86,7 +86,7 @@ You can use a link with the `href` attribute, or a button with the `data-coreui-
8686

8787
### Body scrolling
8888

89-
Scrolling the `<body>` element is disabled when an offcanvas and its backdrop are visible. Use the `data-coreui-scroll` attribute to enable `<body>` scrolling.
89+
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>`.
9090

9191
{{< example >}}
9292
<button class="btn btn-primary" type="button" data-coreui-toggle="offcanvas" data-coreui-target="#offcanvasScrolling" aria-controls="offcanvasScrolling">Enable body scrolling</button>
@@ -97,7 +97,8 @@ Scrolling the `<body>` element is disabled when an offcanvas and its backdrop ar
9797
<button type="button" class="btn-close" data-coreui-dismiss="offcanvas" aria-label="Close"></button>
9898
</div>
9999
<div class="offcanvas-body">
100-
<p>Try scrolling the rest of the page to see this option in action.</p>
100+
<p>Scroll further down the page to see this option in action.
101+
</p>
101102
</div>
102103
</div>
103104
{{< /example >}}
@@ -122,8 +123,7 @@ You can also enable `<body>` scrolling with a visible backdrop.
122123

123124
### Static backdrop
124125

125-
When backdrop is set to static, the offcanvas will not close when clicking outside of it.
126-
126+
When the backdrop is set to static, the Bootstrap offcanvas will remain open when clicking outside of it.
127127
{{< example >}}
128128
<button class="btn btn-primary" type="button" data-coreui-toggle="offcanvas" data-coreui-target="#staticBackdrop" aria-controls="staticBackdrop">
129129
Toggle static offcanvas
@@ -136,7 +136,7 @@ When backdrop is set to static, the offcanvas will not close when clicking outsi
136136
</div>
137137
<div class="offcanvas-body">
138138
<div>
139-
I will not close if you click outside of me.
139+
I won’t close if you click outside of me.
140140
</div>
141141
</div>
142142
</div>
@@ -146,10 +146,10 @@ When backdrop is set to static, the offcanvas will not close when clicking outsi
146146

147147
{{< deprecated-in "5.0.0" >}} {{< added-in "4.2.6" >}}
148148

149-
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`.
149+
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`.
150150

151151
{{< callout warning >}}
152-
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.
152+
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.
153153
{{< /callout >}}
154154

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

169169
{{< added-in "4.2.6" >}}
170170

171-
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.
171+
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.
172172

173173
{{< example >}}
174174
<button class="btn btn-primary d-lg-none" type="button" data-coreui-toggle="offcanvas" data-coreui-target="#offcanvasResponsive" aria-controls="offcanvasResponsive">Toggle offcanvas</button>
@@ -186,7 +186,7 @@ Responsive offcanvas classes hide content outside the viewport from a specified
186186
</div>
187187
{{< /example >}}
188188

189-
Responsive offcanvas classes are available across for each breakpoint.
189+
Responsive offcanvas classes are available for each breakpoint.
190190

191191
- `.offcanvas`
192192
- `.offcanvas-sm`
@@ -197,14 +197,14 @@ Responsive offcanvas classes are available across for each breakpoint.
197197

198198
## Placement
199199

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

202-
- `.offcanvas-start` places offcanvas on the left of the viewport (shown above)
203-
- `.offcanvas-end` places offcanvas on the right of the viewport
204-
- `.offcanvas-top` places offcanvas on the top of the viewport
205-
- `.offcanvas-bottom` places offcanvas on the bottom of the viewport
202+
- `.offcanvas-start` places the offcanvas on the left side of the viewport (as shown above)
203+
- `.offcanvas-end` places the offcanvas on the right side of the viewport
204+
- `.offcanvas-top` places offcanvas at the top of the viewport
205+
- `.offcanvas-bottom` places offcanvas at the bottom of the viewport
206206

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

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

257257
{{< bootstrap-compatibility >}}
258258

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

261261
- `.offcanvas` hides the content
262262
- `.offcanvas.show` shows the content
263263
- `.offcanvas-start` hides the offcanvas on the left
264264
- `.offcanvas-end` hides the offcanvas on the right
265-
- `.offcanvas-top` hides the offcanvas on the top
266-
- `.offcanvas-bottom` hides the offcanvas on the bottom
265+
- `.offcanvas-top` hides the offcanvas at the top
266+
- `.offcanvas-bottom` hides the offcanvas at the bottom
267267

268-
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.
268+
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.
269269

270270
### Via data attributes
271271

272-
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`.
272+
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.
273273

274274
#### Dismiss
275275

276276
{{% js-dismiss "offcanvas" %}}
277277

278278
{{< callout warning >}}
279-
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.
279+
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.
280280
{{< /callout >}}
281281

282282
### Via JavaScript
@@ -297,9 +297,9 @@ const offcanvasList = [...offcanvasElementList].map(offcanvasEl => new coreui.Of
297297
{{< bs-table "table" >}}
298298
| Name | Type | Default | Description |
299299
| --- | --- | --- | --- |
300-
| `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. |
301-
| `keyboard` | boolean | `true` | Closes the offcanvas when escape key is pressed |
302-
| `scroll` | boolean | `false` | Allow body scrolling while offcanvas is open |
300+
| `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. |
301+
| `keyboard` | boolean | `true` | Closes the offcanvas when the escape key is pressed. |
302+
| `scroll` | boolean | `false` | Allows body scrolling while the offcanvas is open.
303303
{{< /bs-table >}}
304304

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

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

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

315315
```js
316-
const bsOffcanvas = new coreui.Offcanvas('#myOffcanvas')
316+
const cuiOffcanvas = new coreui.Offcanvas('#myOffcanvas')
317317
```
318318

319319
{{< bs-table "table" >}}
320320
| Method | Description |
321321
| --- | --- |
322-
| `getInstance` | *Static* method which allows you to get the offcanvas instance associated with a DOM element |
323-
| `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 |
324-
| `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).|
325-
| `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).|
326-
| `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). |
322+
| `getInstance` | *Static* method that allows you to obtain the offcanvas instance associated with a DOM element |
323+
| `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 |
324+
| `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).|
325+
| `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).|
326+
| `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).
327327
{{< /bs-table >}}
328328

329329
### Events
330330

331331
CoreUI for Bootstrap's offcanvas class exposes a few events for hooking into offcanvas functionality.
332332

333333
{{< bs-table "table" >}}
334-
| Event type | Description |
334+
| Event Type | Description |
335335
| --- | --- |
336-
| `hide.coreui.offcanvas` | This event is fired immediately when the `hide` method has been called. |
337-
| `hidden.coreui.offcanvas` | This event is fired when an offcanvas element has been hidden from the user (will wait for CSS transitions to complete). |
338-
| `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`. |
339-
| `show.coreui.offcanvas` | This event fires immediately when the `show` instance method is called. |
340-
| `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). |
336+
| `hide.coreui.offcanvas` | This event is fired immediately after the `hide` method has been called. |
337+
| `hidden.coreui.offcanvas` | This event is fired when an offcanvas element is hidden from the user (it will wait for CSS transitions to complete). |
338+
| `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`. |
339+
| `show.coreui.offcanvas` | This event fires immediately when the `show` instance method is invoked. |
340+
| `shown.coreui.offcanvas` | This event is fired when an offcanvas element becomes visible to the user (it will wait for CSS transitions to complete).
341341
{{< /bs-table >}}
342342

343343
```js
@@ -351,7 +351,7 @@ myOffcanvas.addEventListener('hidden.coreui.offcanvas', event => {
351351

352352
### CSS variables
353353

354-
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.
354+
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.
355355

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

docs/layouts/shortcodes/scss-docs.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,10 @@
4545
{{- $match = replace $match " !default" "" -}}
4646
{{- end -}}
4747

48+
{{- if in $name "css-vars" -}}
49+
{{- $match = replace $match "--#{$prefix}" "--cui-" -}}
50+
{{- end -}}
51+
4852
{{- $format := (index (complement .Page.AlternativeOutputFormats .Page.OutputFormats) 0).Name -}}
4953

5054
{{- if eq $format "markdown" -}}

0 commit comments

Comments
 (0)