+
+Button
+
+
+`}
+ id="button-preview"
+/>
+
+
diff --git a/site/src/content/docs/components/button-group.mdx b/site/src/content/docs/components/button-group.mdx
index 34a3055ad5..635b186b09 100644
--- a/site/src/content/docs/components/button-group.mdx
+++ b/site/src/content/docs/components/button-group.mdx
@@ -47,25 +47,33 @@ These classes can also be added to groups of links, as an alternative to the [`.
Combine button-like checkbox and radio toggle buttons into a seamless looking button group.
-
-
-
-
-
-
-
-
+
+
+
`} />
-
-
-
-
-
-
-
-
+
+
+
`} />
## Button toolbar
@@ -211,10 +219,16 @@ Make a set of buttons appear vertically stacked rather than horizontally. **Spli
`} />
-
-
-
-
-
-
+
+
+
`} />
diff --git a/site/src/content/docs/components/buttons.mdx b/site/src/content/docs/components/buttons.mdx
index 0d161ccf4b..3819ea1eaf 100644
--- a/site/src/content/docs/components/buttons.mdx
+++ b/site/src/content/docs/components/buttons.mdx
@@ -8,19 +8,25 @@ import { getData } from '@libs/data'
## Base class
-Bootstrap has a base `.btn` class that sets up basic styles such as padding and content alignment. By default, `.btn` controls have a transparent border and background color, and lack any explicit focus and hover styles.
+Buttons have a standard `.btn` class that sets up basic styles such as padding and content alignment, along with fallback visual styles for basic accessibility. Change this class to another button class to apply different visual styles for a specific button variant and theme.
Base class`} />
-The `.btn` class is intended to be used in conjunction with our button variants, or to serve as a basis for your own custom styles.
+The `.btn` class is intended to be a starting point for your own custom button styles, while our provided button variants used in conjunction with our button variants, or to serve as a basis for your own custom styles.
When using `.btn` without a modifier, be sure to add some explicit `:focus-visible` styles.
+## Playground
+
+Bootstrap includes several button variants, each serving its own semantic purpose, with a few extras thrown in for more control. Combined with our utilities, you have a very powerful set of defaults to choose from.
+
+
+
## Variants
-Bootstrap includes several button variants, each serving its own semantic purpose, with a few extras thrown in for more control.
+Compare all variants at once:
`
@@ -31,6 +37,27 @@ Bootstrap includes several button variants, each serving its own semantic purpos
+## Styled buttons
+
+Add visual depth to solid buttons with gradients and shadows using the `.btn-styled` modifier class. This provides a more three-dimensional appearance that can be customized further with CSS variables.
+
+ ``)]} />
+
+The gradient and shadow can be customized via CSS variables:
+
+
+| Variable | Description |
+| --- | --- |
+| `--bs-btn-gradient-start` | Top of gradient (default: `rgb(255 255 255 / 12.5%)`) |
+| `--bs-btn-gradient-end` | Bottom of gradient (default: `rgb(0 0 0 / 7.5%)`) |
+| `--bs-btn-border-mix-color` | Color to mix with the button background (default: `#000`) |
+| `--bs-btn-border-mix-amount` | Amount of color to mix with the button background (default: `10%`) |
+| `--bs-btn-border-hover-mix-amount` | Amount of color to mix with the button background on hover (default: `12.5%`) |
+| `--bs-btn-border-active-mix-amount` | Amount of color to mix with the button background on active (default: `20%`) |
+| `--bs-btn-shadow` | Resting state shadow |
+| `--bs-btn-active-shadow` | Pressed/active state shadow |
+
+
## Disable text wrapping
If you donât want the button text to wrap, you can add the `.text-nowrap` class to the button. In Sass, you can set `$btn-white-space: nowrap` to disable text wrapping for each button.
@@ -41,198 +68,184 @@ The `.btn` classes are designed to be used with the `
-Large button`} />
+Large button
+Large button`} />
+
+Small button
+Small button`} />
-Small button
-Small button`} />
+Extra small button
+Extra small button`} />
You can even roll your own custom sizing with CSS variables:
-
Custom button
`} />
+## Icon buttons
+
+Use `.btn-icon` for square buttons that contain only an icon. This class sets `aspect-ratio: 1` and removes padding, making the button perfectly square based on its `min-height`. Always include an `aria-label` attribute on icon-only buttons to ensure they are accessible to screen reader users.
+
+
+
+
+
+
+
+
+
+ `} />
+
+Combine with size classes for different icon button sizes:
+
+
+
+
+
+
+
+
+
+
+
+
+ `} />
+
## Disabled state
-Make buttons look inactive by adding the `disabled` boolean attribute to any `` element. Disabled buttons have `pointer-events: none` applied to, preventing hover and active states from triggering.
+Make buttons look inactive by adding the `disabled` boolean attribute to any `` element. Disabled buttons have `pointer-events: none` applied to, preventing hover and active states from triggering, and some additional styling to indicate the disabled state.
-Primary button
-Button
-Primary button
-Button`} />
+Primary button
+Button
+Primary button
+Button`} />
-Disabled buttons using the `` element behave a bit different:
+### Disabled links
-- ``s donât support the `disabled` attribute, so you must add the `.disabled` class to make it visually appear disabled.
-- Some future-friendly styles are included to disable all `pointer-events` on anchor buttons.
-- Disabled buttons using `` should include the `aria-disabled="true"` attribute to indicate the state of the element to assistive technologies.
-- Disabled buttons using `` *should not* include the `href` attribute.
+Disabled buttons using the `` element behave a bit different, and if you need to keep the `href` attribute, you may need additional HTML to fully disable the link functionality. Use the `.disabled` class instead of the attribute on `` elements to make them visually appear disabled.
-Primary link
-Link`} />
+Primary link
+Link`} />
-### Link functionality caveat
+If there's an `href` attribute, add `tabindex="-1"` and `aria-disabled="true"` to prevent keyboard focus and assistive technologies from interacting with the link.
-To cover cases where you have to keep the `href` attribute on a disabled link, the `.disabled` class uses `pointer-events: none` to try to disable the link functionality of ``s. Note that this CSS property is not yet standardized for HTML, but all modern browsers support it. In addition, even in browsers that do support `pointer-events: none`, keyboard navigation remains unaffected, meaning that sighted keyboard users and users of assistive technologies will still be able to activate these links. So to be safe, in addition to `aria-disabled="true"`, also include a `tabindex="-1"` attribute on these links to prevent them from receiving keyboard focus, and use custom JavaScript to disable their functionality altogether.
+Primary link
+Link`} />
-Primary link
-Link`} />
+You may also want to use custom JavaScript to disable the link functionality altogether.
## Block buttons
-Create responsive stacks of full-width, âblock buttonsâ like those in Bootstrap 4 with a mix of our display and gap utilities. By using utilities instead of button-specific classes, we have much greater control over spacing, alignment, and responsive behaviors.
+Use the `.d-grid` utility to create responsive stacks of full-width âblock buttonsâ. Space them out with gap utilities.
- Button
- Button
+ Button
+ Button
`} />
Here we create a responsive variation, starting with vertically stacked buttons until the `md` breakpoint, where `.d-md-block` replaces the `.d-grid` class, thus nullifying the `gap-2` utility. Resize your browser to see them change.
- Button
- Button
+ Button
+ Button
`} />
You can adjust the width of your block buttons with grid column width classes. For example, for a half-width âblock buttonâ, use `.col-6`. Center it horizontally with `.mx-auto`, too.
- Button
- Button
+ Button
+ Button
`} />
Additional utilities can be used to adjust the alignment of buttons when horizontal. Here weâve taken our previous responsive example and added some flex utilities and a margin utility on the button to right-align the buttons when theyâre no longer stacked.
- Button
- Button
+ Button
+ Button
`} />
## Toggle buttons
-Create button-like checkboxes and radio buttons by using `.btn` styles rather than `.form-check-label` on the `
-Different variants of `.btn`, such as the various outlined styles, are supported.
+
+
+ Toggle
+
-
-Single toggle
+
+
+ Disabled
+
-
-Checked
-
-
-Checked success radio
-
-
-Danger radio`} />
+
+
+ Toggle
+ `} />
## Button plugin
The button plugin allows you to create simple on/off toggle buttons.
-Visually, these toggle buttons are identical to the [checkbox toggle buttons]([[docsref:/forms/checkbox]]). However, they are conveyed differently by assistive technologies: the checkbox toggles will be announced by screen readers as âcheckedâ/ânot checkedâ (since, despite their appearance, they are fundamentally still checkboxes), whereas these toggle buttons will be announced as âbuttonâ/âbutton pressedâ. The choice between these two approaches will depend on the type of toggle you are creating, and whether or not the toggle will make sense to users when announced as a checkbox or as an actual button.
+Visually, these toggle buttons are identical to our [input toggle buttons](#toggle-buttons), but are conveyed differently by assistive technologies. Checkbox toggles will be announced by screen readers as "checked"/"not checked"as they are checkboxes under the hood. The JavaScript toggle buttons are announced as "button"/"button pressed". Itâs up to you to decide which approach makes more sense for your use case.
### Toggle states
Add `data-bs-toggle="button"` to toggle a buttonâs `active` state. If youâre pre-toggling a button, you must manually add the `.active` class **and** `aria-pressed="true"` to ensure that it is conveyed appropriately to assistive technologies.
-
- Toggle button
- Active toggle button
- Disabled toggle button
-
`} />
+Toggle button
+ Active toggle button
+ Disabled toggle button`} />
+
+Toggle link
+ Active toggle link
+ Disabled toggle link`} />
### Methods
@@ -264,44 +277,111 @@ document.querySelectorAll('.btn').forEach(buttonElement => {
### Variables
-
+Buttons use CSS variables for real-time customization. These are set on the base `.btn` class and inherited by all button variants.
-Each `.btn-*` modifier class updates the appropriate CSS variables to minimize additional CSS rules with our `button-variant()`, `button-outline-variant()`, and `button-size()` mixins.
-
-Hereâs an example of building a custom `.btn-*` modifier class as we do for the buttons unique to our docs by reassigning Bootstrapâs CSS variables with a mixture of our own CSS and Sass variables.
-
-Custom button
-`} />
-
-
+Each variant class (`.btn-solid`, `.btn-outline`, etc.) updates these variables based on the current theme color, allowing buttons to adapt automatically when used with `.theme-*` classes.
### Sass variables
+Base button styling uses these Sass variables for padding, typography, and sizing across all button variants.
+
-### Sass map
+### Sass maps
-Button variantsâincluding all their statesâare defined in the `$button-variants` Sass map. This map identifies which theme color tokens to use for each variant's state.
+#### Variants map
-For example, a solid button uses the same `bg` token for its background and border colors because we want it to have a seamless look.
+Button variants are defined in the `$button-variants` Sass map. Each variant specifies which theme color tokens to use for its base, hover, and active states. The map uses token names (like `"bg"`, `"contrast"`, `"border"`) that reference the current theme's color palette.
-### Sass mixins
+To add a custom variant, extend the map before importing Bootstrapâs buttons:
+
+```scss
+@use "bootstrap/scss/buttons/button" with (
+ $button-variants: (
+ "solid": ( /* ... */ ),
+ "outline": ( /* ... */ ),
+ "subtle": ( /* ... */ ),
+ "text": ( /* ... */ ),
+ "ghost": (
+ "base": (
+ "bg": "transparent",
+ "color": "text",
+ "border-color": "transparent"
+ ),
+ "hover": (
+ "bg": "bg-subtle",
+ "color": "text-emphasis"
+ ),
+ "active": (
+ "bg": "bg-subtle",
+ "color": "text-emphasis"
+ )
+ )
+ )
+);
+```
-There are three mixins for buttons: button and button outline variant mixins (both based on `$theme-colors`), plus a button size mixin.
+To remove a variant you don't need, use Sass's `map.remove()`:
-
+```scss
+@use "sass:map";
-{/*
+@use "bootstrap/scss/buttons/button" as *button* with (
+ $button-variants: map.remove($button-variants, "text", "subtle")
+);
+```
-*/}
+#### Sizes map
+
+Button sizes are defined in the `$button-sizes` map. Each size specifies padding, font size, line height, border radius, and minimum height. The loop generates `.btn-xs`, `.btn-sm`, and `.btn-lg` classes.
+
+
+
+To add or modify sizes, extend the map:
+
+```scss
+@use "bootstrap/scss/buttons/button" with (
+ $button-sizes: (
+ "xs": ( /* ... */ ),
+ "sm": ( /* ... */ ),
+ "lg": ( /* ... */ ),
+ "xl": (
+ "padding-y": .75rem,
+ "padding-x": 1.25rem,
+ "font-size": var(--bs-font-size-lg),
+ "line-height": 1.5rem,
+ "border-radius": var(--bs-border-radius-lg),
+ "min-height": 3.25rem
+ )
+ )
+);
+```
### Sass loops
-Button variants (for regular and outline buttons) use their respective mixins with our `$theme-colors` map to generate the modifier classes in `scss/_buttons.scss`.
+#### Variant loop
+
+The variant loop iterates over `$button-variants` to generate each variant class. It sets CSS variables for base, hover, active, and disabled states using the theme color tokens defined in the map.
-{/* */}
+
+
+#### Size loop
+
+The size loop iterates over `$button-sizes` to generate size modifier classes, setting the appropriate CSS variables for each size.
+
+```scss
+@each $size, $properties in $button-sizes {
+ .btn-#{$size} {
+ --bs-btn-min-height: #{map.get($properties, "min-height")};
+ --bs-btn-padding-y: #{map.get($properties, "padding-y")};
+ --bs-btn-padding-x: #{map.get($properties, "padding-x")};
+ --bs-btn-font-size: #{map.get($properties, "font-size")};
+ --bs-btn-line-height: #{map.get($properties, "line-height")};
+ --bs-btn-border-radius: #{map.get($properties, "border-radius")};
+ }
+}
+```
diff --git a/site/src/content/docs/getting-started/approach.mdx b/site/src/content/docs/getting-started/approach.mdx
index b7161bbec1..9ceea05f34 100644
--- a/site/src/content/docs/getting-started/approach.mdx
+++ b/site/src/content/docs/getting-started/approach.mdx
@@ -71,7 +71,7 @@ We use [Autoprefixer](https://github.com/postcss/autoprefixer) to handle intende
## Guiding principles
-Beyond what Bootstrap does, here's _why_ we do itâour philosophy for building on the web. At a high level, here's what guides our approach:
+Beyond what Bootstrap does, here's *why* we do itâour philosophy for building on the web. At a high level, here's what guides our approach:
- Components should be responsive and mobile-first
- Components should be built with a base class and extended via modifier classes
@@ -101,7 +101,7 @@ We use two `z-index` scales in Bootstrapâelements within a component and overl
Some components in Bootstrap are built with overlapping elements to prevent double borders without modifying the `border` property. For example, button groups, input groups, and pagination. These components share a standard `z-index` scale of `0` through `3`, matching our expectations of highest user priority.
- `0` is for default states (initial, not actually set)
-- `1` is for `:hover`, lowest because while it indicates user intent, nearly _anything_ can be hovered.
+- `1` is for `:hover`, lowest because while it indicates user intent, nearly *anything* can be hovered.
- `2` is for `:active`/`.active`, second highest because they indicate state.
- `3` is for `:focus`, highest because focused elements are in view and at the userâs attention.
diff --git a/site/src/content/docs/guides/quickstart.mdx b/site/src/content/docs/guides/quickstart.mdx
index a5c06346d7..b44db56e9d 100644
--- a/site/src/content/docs/guides/quickstart.mdx
+++ b/site/src/content/docs/guides/quickstart.mdx
@@ -27,7 +27,7 @@ Get started using Bootstrap in seconds by including our production-ready CSS and