Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .bundlewatch.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
},
{
"path": "./dist/css/bootstrap.css",
"maxSize": "40.75 kB"
"maxSize": "41.0 kB"
},
{
"path": "./dist/css/bootstrap.min.css",
Expand Down
10 changes: 8 additions & 2 deletions scss/_root.scss
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,14 @@ $root-tokens: defaults(
// scss-docs-end root-focus-variables

// scss-docs-start root-form-variables
--input-bg: var(--bg-body),
--input-color: var(--fg-body),
--control-bg: var(--bg-body),
--control-fg: var(--fg-body),
--control-checked-bg: var(--primary-base),
--control-checked-border-color: var(--control-checked-bg),
--control-active-bg: var(--primary-base),
--control-active-border-color: var(--control-active-bg),
--control-disabled-bg: var(--bg-3),
--control-disabled-opacity: .65,

--btn-input-min-height: 2.375rem,
--btn-input-padding-y: .375rem,
Expand Down
27 changes: 15 additions & 12 deletions scss/forms/_check.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,25 @@ $check-tokens: () !default;
// stylelint-disable-next-line scss/dollar-variable-default
$check-tokens: defaults(
(
--check-size: 1rem,
--check-bg: transparent,
--check-border-color: var(--border-color),
--check-checked-bg: var(--primary-base),
--check-checked-border-color: var(--primary-base),
--check-indeterminate-bg: var(--primary-base),
--check-indeterminate-border-color: var(--primary-base),
--check-disabled-bg: var(--bg-3),
--check-disabled-opacity: .65,
--check-checked-bg: var(--control-checked-bg),
--check-checked-border-color: var(--control-checked-border-color),
--check-indeterminate-bg: var(--control-checked-bg),
--check-indeterminate-border-color: var(--control-checked-border-color),
--check-active-bg: var(--control-active-bg),
--check-active-border-color: var(--control-active-border-color),
--check-disabled-bg: var(--control-disabled-bg),
--check-disabled-opacity: var(--control-disabled-opacity),
),
$check-tokens
);
// scss-docs-end check-tokens
// stylelint-enable custom-property-no-missing-var-function

@layer forms {
b-checkgroup {
.checkgroup {
display: flex;
gap: var(--gap, .5rem);
align-items: var(--align-items, start);
Expand All @@ -53,8 +56,8 @@ $check-tokens: defaults(
flex-shrink: 0;
grid-row-start: 1;
grid-column-start: 1;
width: 1rem;
height: 1rem;
width: var(--check-size);
height: var(--check-size);
}

:where(input) {
Expand All @@ -63,7 +66,7 @@ $check-tokens: defaults(
background-color: var(--theme-bg, var(--check-bg));
border: 1px solid var(--theme-bg, var(--check-border-color));
// stylelint-disable-next-line property-disallowed-list
border-radius: .25em;
border-radius: .3em;
}

:where(input:checked, input:indeterminate) {
Expand All @@ -78,15 +81,15 @@ $check-tokens: defaults(
&:has(input:checked) .checked,
&:has(input:indeterminate) .indeterminate {
display: block;
color: var(--primary-contrast);
color: var(--theme-contrast, var(--primary-contrast));
stroke: currentcolor;
}

&:has(input:disabled) {
--check-bg: var(--check-disabled-bg);

~ label {
color: var(--secondary-text);
color: var(--fg-3);
cursor: default;
}
}
Expand Down
2 changes: 1 addition & 1 deletion scss/forms/_chip-input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ $chip-input-tokens: defaults(
opacity: 1;

> .chip {
opacity: .65;
opacity: var(--control-disabled-opacity);

.chip-dismiss {
pointer-events: none;
Expand Down
2 changes: 1 addition & 1 deletion scss/forms/_floating-labels.scss
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ $form-floating-tokens: defaults(
z-index: -1;
height: var(--form-floating-label-height);
content: "";
background-color: var(--input-bg);
background-color: var(--control-bg);
@include border-radius(var(--btn-input-border-radius));
}
}
Expand Down
4 changes: 2 additions & 2 deletions scss/forms/_form-control.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ $form-control-tokens: defaults(
--control-padding-x: var(--btn-input-padding-x),
--control-font-size: var(--btn-input-font-size),
--control-line-height: var(--btn-input-line-height),
--control-color: var(--input-color),
--control-bg: var(--input-bg),
--control-color: var(--control-fg),
--control-bg: var(--control-bg),
--control-border-width: var(--border-width),
--control-border-color: var(--border-color),
--control-border-radius: var(--border-radius),
Expand Down
15 changes: 8 additions & 7 deletions scss/forms/_radio.scss
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,21 @@ $radio-tokens: () !default;
// stylelint-disable-next-line scss/dollar-variable-default
$radio-tokens: defaults(
(
--radio-size: 1rem,
--radio-bg: transparent,
--radio-border-color: var(--border-color),
--radio-checked-bg: var(--primary-base),
--radio-checked-border-color: var(--primary-base),
--radio-disabled-bg: var(--bg-3),
--radio-disabled-opacity: .65,
--radio-checked-bg: var(--control-checked-bg),
--radio-checked-border-color: var(--control-checked-border-color),
--radio-disabled-bg: var(--control-disabled-bg),
--radio-disabled-opacity: var(--control-disabled-opacity),
),
$radio-tokens
);
// scss-docs-end radio-tokens
// stylelint-enable custom-property-no-missing-var-function

@layer forms {
b-radiogroup {
.radiogroup {
display: flex;
gap: var(--gap, .5rem);
align-items: var(--align-items, start);
Expand All @@ -45,8 +46,8 @@ $radio-tokens: defaults(

position: relative;
flex-shrink: 0;
width: 1rem;
height: 1rem;
width: var(--radio-size);
height: var(--radio-size);
margin-block: .125rem;
appearance: none;
background-color: var(--theme-bg, var(--radio-bg));
Expand Down
6 changes: 3 additions & 3 deletions scss/forms/_switch.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ $switch-tokens: defaults(
--switch-border-width: var(--border-width),
--switch-border-color: var(--border-color),
--switch-indicator-bg: var(--white),
--switch-checked-bg: var(--primary-base),
--switch-checked-bg: var(--control-checked-bg),
--switch-checked-border-color: var(--switch-checked-bg),
--switch-checked-indicator-bg: var(--white),
--switch-disabled-bg: var(--bg-3),
--switch-disabled-bg: var(--control-disabled-bg),
--switch-disabled-indicator-bg: var(--fg-3),
),
$switch-tokens
Expand Down Expand Up @@ -62,7 +62,7 @@ $switch-tokens: defaults(
width: calc(var(--switch-height) - calc(var(--switch-padding) * 2) - var(--switch-border-width) * 2);
height: calc(var(--switch-height) - calc(var(--switch-padding) * 2) - var(--switch-border-width) * 2);
content: "";
background-color: var(--switch-indicator-bg);
background-color: var(--theme-contrast, var(--switch-indicator-bg));
// stylelint-disable-next-line property-disallowed-list
border-radius: 50%;
box-shadow: 0 1px 2px rgba($black, .1);
Expand Down
4 changes: 2 additions & 2 deletions site/src/components/shortcodes/StepperPlayground.astro
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,12 @@ const stepCounts = [3, 4, 5, 6]

<div class="vstack gap-1">
<label class="form-label fw-semibold mb-0 user-select-none">&nbsp;</label>
<b-checkgroup class="py-2">
<div class="checkgroup py-2">
<div class="switch">
<input type="checkbox" value="" id="stepper-fullwidth" role="switch" switch>
</div>
<label for="stepper-fullwidth">Full width</label>
</b-checkgroup>
</div>
</div>
</div>
</div>
Expand Down
10 changes: 5 additions & 5 deletions site/src/content/docs/components/dropdown.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -273,16 +273,16 @@ Put a form within a dropdown menu, or make it into a dropdown menu, and use [mar
<label for="exampleDropdownFormPassword1" class="form-label">Password</label>
<input type="password" class="form-control" id="exampleDropdownFormPassword1" placeholder="Password">
</div>
<b-checkgroup>
<div class="checkgroup">
<div class="check">
<input type="checkbox" id="checkLabel" />
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'>
<path class="checked" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/>
<path class="indeterminate" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10h8'/>
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'>
<path class="checked" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m4 8 3 3 5-5'/>
<path class="indeterminate" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M5 8h6'/>
</svg>
</div>
<label for="checkLabel">Example new checkbox</label>
</b-checkgroup>
</div>
<div class="vstack gap-2">
<button type="submit" class="btn-solid theme-primary">Sign in</button>
<a class="btn-ghost theme-secondary" href="#">New around here? Sign up</a>
Expand Down
73 changes: 34 additions & 39 deletions site/src/content/docs/forms/checkbox.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@ toc: true

import { getData } from '@libs/data'

**Trialing new components with the following rules:**

- New components are purely components, they don't assume layout of any kind.
- New options for form layout:
- Use new form groups to lay out your forms: `.control-group`, `.check-group`, `.radio-group`.
- Use helpers to lay out your forms—`.hstack` and `.vstack`—with utilities.

## Basic checkbox

All checkbox styling is contained to a wrapper class, `.check`. This does the following:
Expand All @@ -27,9 +20,9 @@ Checkbox layout and labels are handled with additional HTML and CSS.

<Example code={`<div class="check">
<input type="checkbox" id="check" checked />
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'>
<path class="checked" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/>
<path class="indeterminate" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10h8'/>
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'>
<path class="checked" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m4 8 3 3 5-5'/>
<path class="indeterminate" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4.5 8.5h6'/>
</svg>
</div>`} />

Expand All @@ -39,87 +32,89 @@ Checkboxes can utilize the indeterminate pseudo class when manually set via Java

<Example addStackblitzJs class="bd-example-indeterminate" code={`<div class="check">
<input type="checkbox" id="checkIndeterminate" />
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'>
<path class="checked" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/>
<path class="indeterminate" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10h8'/>
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'>
<path class="checked" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m4 8 3 3 5-5'/>
<path class="indeterminate" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4.5 8.5h6'/>
</svg>
</div>`} />

## Label

Wrap the `.check` in a `<b-checkgroup>` layout component and add your label. We use a custom element for layout here that sets some basic flexbox styling.
Wrap the `.check` in a `.checkgroup` layout wrapper and add your label. This sets some basic flexbox styling.

Consider margin utilities for additional spacing, and flex utilities for alignment.

<Example code={`<b-checkgroup>
<Example code={`<div class="checkgroup">
<div class="check">
<input type="checkbox" id="checkLabel" />
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'>
<path class="checked" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/>
<path class="indeterminate" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10h8'/>
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'>
<path class="checked" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m4 8 3 3 5-5'/>
<path class="indeterminate" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4.5 8.5h6'/>
</svg>
</div>
<label for="checkLabel">Example new checkbox</label>
</b-checkgroup>`} />
</div>`} />

## Theme colors

Modify the appearance of checked checkboxes by adding the `.theme-{color}` class to the `.check` element. This will set the checked background and border color to the theme color.

<Example class="d-flex flex-column gap-2" code={getData('theme-colors').map((themeColor) => `<b-checkgroup>
<Example class="d-flex flex-column gap-2" code={getData('theme-colors').map((themeColor) => `<div class="checkgroup">
<div class="check theme-${themeColor.name}">
<input type="checkbox" id="check${themeColor.name}" checked />
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'>
<path class="checked" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/>
<path class="indeterminate" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10h8'/>
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'>
<path class="checked" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m4 8 3 3 5-5'/>
<path class="indeterminate" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4.5 8.5h6'/>
</svg>
</div>
<label for="check${themeColor.name}">Example ${themeColor.name} checkbox</label>
</b-checkgroup>`)} />
</div>`)} />

## Description

With this layout approach, you can easily add a description or other content after the label. Here we use another custom element, `<b-vstack>`, to stack the label and description.

<Example code={`<b-checkgroup>
<Example code={`<div class="checkgroup">
<div class="check">
<input type="checkbox" id="checkDescription" />
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'>
<path class="checked" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/>
<path class="indeterminate" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10h8'/>
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'>
<path class="checked" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m4 8 3 3 5-5'/>
<path class="indeterminate" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4.5 8.5h6'/>
</svg>
</div>
<b-vstack>
<label for="checkDescription">Example new checkbox</label>
<small class="description">Supporting description for the above label.</small>
</b-vstack>
</b-checkgroup>`} />
</div>`} />

## Disabled

Add the `disabled` attribute and the associated `<label>`s are automatically styled to match with a lighter color to help indicate the input’s state.

<Example code={`<b-checkgroup>
<Example code={`<div class="checkgroup">
<div class="check">
<input type="checkbox" id="checkDisabled" disabled />
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'>
<path class="checked" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/>
<path class="indeterminate" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10h8'/>
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'>
<path class="checked" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m4 8 3 3 5-5'/>
<path class="indeterminate" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4.5 8.5h6'/>
</svg>
</div>
<label for="checkDisabled">Example new checkbox</label>
</b-checkgroup>`} />
</div>`} />

Applies to checked states, too.

<Example code={`<b-checkgroup>
<Example code={`<div class="checkgroup">
<div class="check">
<input type="checkbox" id="checkDisabledChecked" checked disabled />
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'>
<path class="checked" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/>
<path class="indeterminate" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10h8'/>
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'>
<path class="checked" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m4 8 3 3 5-5'/>
<path class="indeterminate" fill='none' stroke='currentcolor' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M4.5 8.5h6'/>
</svg>
</div>
<label for="checkDisabledChecked">Example new checkbox</label>
</b-checkgroup>`} />
</div>`} />

## CSS

Expand Down
Loading