Skip to content

feat: add data-kumo attributes to component root elements#207

Closed
mattrothenberg wants to merge 5 commits intomainfrom
feat/data-kumo-attributes
Closed

feat: add data-kumo attributes to component root elements#207
mattrothenberg wants to merge 5 commits intomainfrom
feat/data-kumo-attributes

Conversation

@mattrothenberg
Copy link
Copy Markdown
Collaborator

Summary

Add data-kumo attributes to component root elements to enable targeted CSS resets in consuming applications (like Stratus) that have conflicting global styles.

Problem

Stratus and other consuming applications have global CSS that pollutes Kumo components - e.g., button backgrounds, SVG fills, input label margins. Base UI provides state attributes (data-checked, data-disabled, etc.) but no component identification attributes.

Solution

Add data-kumo="component-name" attributes to component root elements, enabling targeted resets:

/* Reset button backgrounds that global styles may have polluted */
[data-kumo="button"] { background: revert; }

/* Reset label margins that global styles may have added */
[data-kumo="field"] label { margin: 0; }

Components Updated (18 total)

Component Attributes
Badge data-kumo="badge"
Button data-kumo="button", data-kumo="link-button"
Checkbox data-kumo="checkbox", data-kumo="checkbox-group"
Collapsible data-kumo="collapsible", data-kumo="collapsible-trigger", data-kumo="collapsible-content"
Combobox data-kumo="combobox", data-kumo="combobox-item"
Dialog data-kumo="dialog", data-kumo="dialog-title", data-kumo="dialog-description"
Dropdown data-kumo="dropdown", data-kumo="dropdown-item", data-kumo="dropdown-link-item", data-kumo="dropdown-checkbox-item", data-kumo="dropdown-radio-item", data-kumo="dropdown-label", data-kumo="dropdown-separator"
Field data-kumo="field"
Input data-kumo="input"
Label data-kumo="label"
Link data-kumo="link"
MenuBar data-kumo="menubar", data-kumo="menubar-option"
Popover data-kumo="popover", data-kumo="popover-title", data-kumo="popover-description"
Radio data-kumo="radio", data-kumo="radio-group"
Select data-kumo="select"
Switch data-kumo="switch", data-kumo="switch-group"
Tabs data-kumo="tabs", data-kumo="tabs-list", data-kumo="tabs-tab"
Tooltip data-kumo="tooltip"

Skipped

  • Backdrop elements (simple overlays, unlikely to be polluted by global styles)
  • Specialized components (chart, flow, cloudflare-logo, command-palette, date-pickers, grid)

Testing

  • TypeScript compiles without errors
  • Build succeeds
  • Verified in browser DevTools that attributes appear on rendered elements

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Mar 12, 2026

npm i https://pkg.pr.new/@cloudflare/kumo@207

commit: 7abbf38

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 12, 2026

Docs Preview

View docs preview

Commit: 7abbf38

@mattrothenberg mattrothenberg force-pushed the feat/data-kumo-attributes branch from 7e825d8 to 7820ca9 Compare March 12, 2026 13:08
Add data-kumo attributes to enable targeted CSS resets in consuming
applications that have conflicting global styles (e.g., Stratus).

Components updated:
- Badge, Button, Checkbox, Collapsible, Combobox, Dialog, Dropdown,
  Field, Input, Label, Link, MenuBar, Popover, Radio, Select, Switch,
  Tabs, Tooltip

Example usage in consuming app:
```css
[data-kumo="button"] { background: revert; }
[data-kumo="field"] label { margin: 0; }
```
Enables targeted CSS resets for tooltip triggers that may be affected
by global button styles (e.g., gray backgrounds in Stratus).
- popover-trigger
- dialog-trigger
- dropdown-trigger

Enables targeted CSS resets for all overlay trigger elements.
When asChild or render prop is used, the trigger element is consumer-owned
(e.g., a Kumo Button), so we should not stamp our data-kumo attribute on it.
This prevents CSS resets from accidentally stripping styles from styled buttons.

- tooltip: data-kumo="tooltip-trigger" only when !asChild
- popover: data-kumo="popover-trigger" only when !asChild
- dialog: data-kumo="dialog-trigger" only when !render
- dropdown: data-kumo="dropdown-trigger" only when !effectiveRender
@mattrothenberg mattrothenberg force-pushed the feat/data-kumo-attributes branch from 475b1d1 to 77d1c89 Compare March 12, 2026 14:38
@mattrothenberg
Copy link
Copy Markdown
Collaborator Author

Superseded by #214

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.

1 participant