Skip to content

Document CSS-based sizing for nimble-chip#2896

Draft
fredvisser wants to merge 4 commits intomainfrom
feature/chip-small-size
Draft

Document CSS-based sizing for nimble-chip#2896
fredvisser wants to merge 4 commits intomainfrom
feature/chip-small-size

Conversation

@fredvisser
Copy link
Contributor

@fredvisser fredvisser commented Mar 14, 2026

Pull Request

Rationale

The nimble-chip component needed documentation for how to achieve the 24px compact size variant. Per design guidance, sizing should be done via CSS rather than component attributes, following the same pattern as the spinner component.

Implementation

Added CSS-based sizing documentation and a Storybook size control:

  • chip.stories.ts: Added a size control under the Styles category with "Default (32px)" and "Small (24px)" radio options. Selecting "Small" applies height: var(--ni-nimble-control-slim-height) via inline CSS, matching the spinner approach.
  • chip.mdx: Added a "Sizing" subsection under "Styling" explaining the 32px default and how to achieve 24px using the control-slim-height design token.

No component code changes — sizing is purely a consumer-side CSS override using existing design tokens.

Testing

No new component tests needed since no component code was changed. The sizing control is visible in Storybook.

Checklist

  • I have updated the project documentation to reflect my changes or determined no changes are needed.

Add a 'size' attribute to the chip component with two values:
- 'normal' (default, undefined): 32px height (existing behavior)
- 'small': 24px height using controlSlimHeight token

This is a non-breaking change. Existing chips without a size
attribute continue to render at 32px.

Changes:
- Add ChipSize enum to chip/types.ts
- Add size attribute to Chip class
- Add sizeBehavior utility (mirrors appearanceBehavior pattern)
- Update styles with controlSlimHeight for small variant
- Add unit tests for size attribute
- Update Storybook stories and matrix with size states
- Update Angular directive with size property and tests
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fredvisser sizing is done via css and not attributes. Controls should respond to sizing via css. See spinner sizing docs as an example: https://nimble.ni.dev/storybook/index.html?path=/docs/components-spinner--docs&globals=backgrounds.grid:!true

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See the "current direction" section captured here: #610

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha - refactored to document the CSS approach like we do with the spinner 👍

@fredvisser fredvisser changed the title Add small (24px) size variant to nimble-chip Document CSS-based sizing for nimble-chip Mar 17, 2026
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