Skip to content

Commit ec24bb4

Browse files
feat(label): Add label component
1 parent 8964f61 commit ec24bb4

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

projects/core/src/lib/label.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { computed, Directive, input } from "@angular/core";
2+
import { tv } from "tailwind-variants";
3+
import { NgpLabel } from "ng-primitives/form-field";
4+
5+
const labelVariants = tv({
6+
base: 'flex items-center gap-2 text-sm leading-none font-medium select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50'
7+
});
8+
9+
@Directive({
10+
selector: '[uiLabel]',
11+
exportAs: 'uiLabel',
12+
host: {
13+
'[class]': 'computedClass()'
14+
},
15+
hostDirectives: [NgpLabel],
16+
})
17+
export class UiLabel {
18+
inputClass = input<string>('', { alias: 'class' });
19+
computedClass = computed(() => labelVariants({ class: this.inputClass() }));
20+
}

projects/core/src/public-api.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ export * from './lib/tooltip';
1111
export * from './lib/card';
1212
export * from './lib/toast';
1313
export * from './lib/separator';
14+
export * from './lib/label';
1415
export * from './lib/input';
1516
export * from './lib/form-field';

0 commit comments

Comments
 (0)