Skip to content

Commit 5ac2cfa

Browse files
fix: tailwind on headless (#1031)
1 parent 664b3f1 commit 5ac2cfa

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

packages/kit-headless/src/components/toggle-group/toggle-group-root.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
import type { PropsOf, QRL, Signal } from '@builder.io/qwik';
2-
import { component$, useContextProvider, Slot, useTask$, $ } from '@builder.io/qwik';
2+
import {
3+
component$,
4+
useContextProvider,
5+
Slot,
6+
useTask$,
7+
$,
8+
useStyles$,
9+
} from '@builder.io/qwik';
310
import {
411
toggleGroupRootApiContextId,
512
type Direction,
@@ -8,6 +15,7 @@ import {
815
} from './toggle-group-context';
916
import { useToggleGroup } from './use-toggle';
1017
import { isBrowser, isServer } from '@builder.io/qwik/build';
18+
import styles from './toggle-group.css?inline';
1119

1220
export type ToggleGroupBaseProps = {
1321
/**
@@ -87,6 +95,7 @@ export type ToggleGroupApiProps = (ToggleGroupSingleProps | ToggleGroupMultipleP
8795
export type ToggleGroupRootProps = PropsOf<'div'> & ToggleGroupApiProps;
8896

8997
export const HToggleGroupRoot = component$<ToggleGroupRootProps>((props) => {
98+
useStyles$(styles);
9099
const {
91100
onChange$: _,
92101
disabled = false,
@@ -97,7 +106,6 @@ export const HToggleGroupRoot = component$<ToggleGroupRootProps>((props) => {
97106
} = props;
98107

99108
const commonProps = { role: 'group', 'aria-orientation': orientation, dir: direction };
100-
const orientationClass = orientation === 'vertical' ? 'flex-col' : 'flex-row';
101109

102110
const api = useToggleGroup(props);
103111

@@ -275,8 +283,8 @@ export const HToggleGroupRoot = component$<ToggleGroupRootProps>((props) => {
275283
<div
276284
{...divProps}
277285
{...commonProps}
278-
class={`flex ${orientationClass} items-center gap-1`}
279286
data-qui-togglegroup-root
287+
data-orientation={orientation}
280288
>
281289
<Slot />
282290
</div>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
@layer qui-togglegroup-root {
2+
[data-qui-togglegroup-root] {
3+
display: flex;
4+
align-items: center;
5+
gap: 4px;
6+
}
7+
8+
[data-qui-togglegroup-root][data-orientation='horizontal'] {
9+
flex-direction: row;
10+
}
11+
12+
[data-qui-togglegroup-root][data-orientation='vertical'] {
13+
flex-direction: column;
14+
}
15+
}

0 commit comments

Comments
 (0)