You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: packages/swingset/src/stories/item.mdx
+46-21Lines changed: 46 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,8 @@ import * as ItemStories from './item.stories';
4
4
5
5
Item is a flexible row for lists of accounts, organizations, and settings in Mosaic. It's composed from parts via dot syntax (`Item.Root`, `Item.Media`, `Item.Content`, `Item.Title`, …). `Item.Root` renders as a `<div>` by default; pass it a `render` prop to make a row an interactive link or button, which adds hover and cursor affordances.
6
6
7
+
Set `size` once on `Item.Root` and the row scales as a unit: it fixes the row's height and gap, and `Item.Media` picks the matching column width up from context rather than taking a size of its own.
8
+
7
9
## Example
8
10
9
11
<Story
@@ -18,6 +20,13 @@ Item is a flexible row for lists of accounts, organizations, and settings in Mos
18
20
storyModule={ItemStories}
19
21
/>
20
22
23
+
### Sizes
24
+
25
+
<Story
26
+
name='Sizes'
27
+
storyModule={ItemStories}
28
+
/>
29
+
21
30
### Group
22
31
23
32
<Story
@@ -34,7 +43,7 @@ import { Item } from '@clerk/ui/mosaic/components/item';
@@ -44,46 +53,62 @@ import { Item } from '@clerk/ui/mosaic/components/item';
44
53
<Item.Description>Member</Item.Description>
45
54
</Item.Content>
46
55
<Item.Actions>
47
-
<Buttonvariant='outline'>Manage</Button>
56
+
<Buttonvariant='outline'size='sm'>Manage</Button>
48
57
</Item.Actions>
49
58
</Item.Root>
50
59
</Item.Group>;
51
60
```
52
61
62
+
Media sizes itself from the row, so give it a child that fills its column — an `Avatar.Root` with `size='fit'`, or an icon at `width='100%'`. An action row that has no secondary text uses `Item.Label` in place of `Item.Title`:
|`render`|`data-interactive`| present when a `render` is provided | — |
79
99
80
-
`variant` sets the row's vertical density (`entity` is standard, `action` is denser) and, on interactive rows, promotes the title color.
100
+
`size` fixes the row's height and gap. `Item.Media` reflects the same value as `data-size` and takes its width from it, so the two stay in step without being set twice:
81
101
82
102
```css
83
103
/* Re-theme interactive rows */
84
104
.cl-item[data-interactive] {
85
105
background-color: var(--cl-color-card);
86
106
}
107
+
108
+
/* Widen the media column on compact rows */
109
+
.cl-item-media[data-size='xs'] {
110
+
width: 1.5rem;
111
+
}
87
112
```
88
113
89
-
`Item.Media`sizes to its child and centers it; its height follows the row. Bring your own icon, avatar, or image at whatever dimensions you need, then size the slot by sizing that child. Colors, radii, and spacing all resolve from the Mosaic tokens (`--cl-color-*`, `--cl-radius-*`, `--cl-spacing`).
114
+
`Item.Media`is a square that centers its child. Because the column is sized by the row, give it a child that fills it — an `Avatar.Root` with `size='fit'`, or an icon at `width='100%'` — rather than a fixed pixel size that won't track `size`. Colors, radii, and spacing all resolve from the Mosaic tokens (`--cl-color-*`, `--cl-radius-*`, `--cl-spacing`).
0 commit comments