Skip to content

feat!: narrow string props to bootstrap value unions - #5

Merged
SimonSchick merged 1 commit into
masterfrom
feat/string-unions
Nov 18, 2026
Merged

SimonSchick merged 1 commit into
masterfrom
feat/string-unions

Conversation

@SimonSchick

Copy link
Copy Markdown

Props that map onto a fixed set of Bootstrap classes were typed string, so typos (size="md", fixed="left") compiled and rendered dead classes.

Closed unions (breaking)

Prop Type
size on Button, DropdownToggle, ButtonGroup, Dropdown, InputGroup, Pagination, Label Size ('sm' | 'lg')
Modal.size 'sm' | 'lg' | 'xl'
Table.size, Spinner.size 'sm'
Spinner.type 'border' | 'grow'
Placeholder.animation / size 'glow' | 'wave' / 'xs' | 'sm' | 'lg'
Navbar.fixed / sticky 'top' | 'bottom'
Nav.horizontal 'start' | 'end' | 'center' | 'between' | 'around' | 'evenly'
List.type 'unstyled' | 'inline'
trigger on Tooltip, Popover, TooltipPopoverWrapper Trigger: up to three space-separated 'click' | 'hover' | 'focus' | 'legacy' | 'manual'

Open unions (non-breaking, autocomplete only)

Theme colors and breakpoints are Sass-extensible ($theme-colors, $grid-breakpoints, Col/Row widths), so they keep (string & {}):

  • ThemeColor on every color prop. Button/DropdownToggle add 'link'; FormText adds 'muted' | 'body' | 'white' | ''.
  • boolean | Breakpoint for Navbar.expand, Nav.vertical, ListGroup.horizontal, Table.responsive, Container.fluid.
  • Row cols and Col size/order gain 'auto' / 'first' | 'last'.
  • role on Modal, Offcanvas, ButtonGroup, ButtonToolbar is React's AriaRole. That type is open too; oxlint's jsx-a11y/aria-role catches invalid roles in JSX.

Other

  • Modal.fullscreen now accepts 'xxl' (modal-fullscreen-xxl-down).
  • ThemeColor, Breakpoint, Size, Trigger and TriggerEvent are exported from the barrel.
  • New compile-only test src/__tests__/unions.tsx covers accepted values, custom theme values and @ts-expect-error typos. Two specs that passed nonsense sizes now use real ones.

Migration

Callers passing a string variable to a narrowed prop must narrow it, e.g. size={s as Size}. Literal JSX values that match Bootstrap need no change. This needs a major version (v12).

Checks

lint, format:check, typecheck, test:ci (857 tests), build and build:docs all pass locally.

🤖 Generated with Claude Code

Props that map onto a fixed set of Bootstrap classes were typed as
`string`, so typos like `size="md"` compiled and rendered dead classes.
Theme colors and breakpoints stay open (`string & {}`) because they are
extensible via `$theme-colors` / `$grid-breakpoints`; they gain
autocomplete only.

BREAKING CHANGE: size, Spinner type, Placeholder animation, Navbar
fixed/sticky, Nav horizontal, List type and tooltip/popover trigger
props only accept Bootstrap's values. Callers passing a `string`
variable must narrow it (e.g. `as Size`).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@SimonSchick
SimonSchick marked this pull request as ready for review November 18, 2026 06:06
@SimonSchick
SimonSchick requested a review from Doridian November 18, 2026 06:06
@SimonSchick
SimonSchick merged commit eacd53c into master Nov 18, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants