Skip to content

Add small (24px) size variant to nimble-chip#2896

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

Add small (24px) size variant to nimble-chip#2896
fredvisser wants to merge 2 commits intomainfrom
feature/chip-small-size

Conversation

@fredvisser
Copy link
Contributor

@fredvisser fredvisser commented Mar 14, 2026

Pull Request

🤨 Rationale

The nimble-chip component only supported a single 32px height although we have designs for a 24px variation, and it's required by other recent app designs.

👩‍💻 Implementation

Added a size attribute to nimble-chip with two values:

  • normal (default, undefined): 32px height — existing behavior, no attribute rendered
  • small: 24px height via the controlSlimHeight token

Same font and horizontal padding as the normal variant; only the height changes.

Key files and changes:

  • packages/nimble-components/src/chip/types.ts — new ChipSize enum
  • packages/nimble-components/src/chip/index.tssize attribute on Chip class
  • packages/nimble-components/src/chip/styles.tssizeBehavior for small height override
  • packages/nimble-components/src/utilities/style/size.ts — new sizeBehavior utility, mirrors the existing appearanceBehavior
  • packages/nimble-components/src/utilities/style/size.ts — new sizeBehavior utility, mirrors the existing appearanceBehavior
  • packages/nimble-components/src/utilities/style/size.ts — new sizeBehavior utility, mirrors the existing appearancult value, setting to small, resetting to normal`
  • Added Angular directive tests covering: defaults, template string values, property binding, attribute binding
  • Added sizeStates to the chip matrix story so visual regression tests cover both sizes
  • Build passes; the 4 pre-existing test failures are in RichTextEditor keyboard shortcuts and are unrelated to this change

✅ 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

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