Skip to content

Commit 89fedf2

Browse files
committed
Add sticky-cell tailwind utility
1 parent d1f1258 commit 89fedf2

File tree

3 files changed

+62
-1
lines changed

3 files changed

+62
-1
lines changed

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file.
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org).
66

7+
## [Unreleased]
8+
### Added
9+
* Add `sticky-cell` tailwind utility.
10+
11+
### Changed
12+
* *Nothing*
13+
14+
### Deprecated
15+
* *Nothing*
16+
17+
### Removed
18+
* *Nothing*
19+
20+
### Fixed
21+
* *Nothing*
22+
23+
724
## [0.9.3] - 2025-05-09
825
### Added
926
* *Nothing*

src/tailwind/form/CloseButton.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@ import type { FC, HTMLProps } from 'react';
66
export type CloseButtonProps = {
77
label?: string;
88
onClick?: HTMLProps<HTMLButtonElement>['onClick'];
9+
className?: string;
910
};
1011

11-
export const CloseButton: FC<CloseButtonProps> = ({ onClick, label = 'Close' }) => (
12+
export const CloseButton: FC<CloseButtonProps> = ({ onClick, className, label = 'Close' }) => (
1213
<button
1314
type="button"
1415
onClick={onClick}
1516
className={clsx(
1617
'tw:opacity-50 tw:highlight:opacity-80 tw:transition-opacity',
1718
'tw:rounded-md tw:focus-ring',
19+
className,
1820
)}
1921
aria-label={label}
2022
>

src/tailwind/tailwind.preset.css

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,45 @@
197197
@slot;
198198
}
199199
}
200+
201+
/* For sticky-positioned cells with a background */
202+
@utility sticky-cell-base {
203+
@apply tw:z-1 tw:relative tw:sticky;
204+
@apply tw:before:absolute tw:before:bg-lm-table-border tw:dark:before:bg-dm-table-border tw:before:-z-2;
205+
@apply tw:after:absolute tw:after:bg-lm-primary tw:dark:after:bg-dm-primary tw:after:-z-1;
206+
207+
&:before, &:after {
208+
content: '';
209+
}
210+
&:first-child:after {
211+
left: 0;
212+
}
213+
}
214+
215+
@utility sticky-cell {
216+
@apply tw:sticky-cell-base;
217+
218+
&:before {
219+
inset: -1px 0 -1px 0;
220+
}
221+
&:first-child:before {
222+
left: 0;
223+
}
224+
&:after {
225+
inset: 0 0 0 0;
226+
}
227+
}
228+
229+
@utility sticky-cell-separated {
230+
@apply tw:sticky-cell-base;
231+
232+
&:before {
233+
inset: -1px -1px -1px 0;
234+
}
235+
&:first-child:before {
236+
left: -1px;
237+
}
238+
&:after {
239+
inset: 0 0 0 1px;
240+
}
241+
}

0 commit comments

Comments
 (0)