@gluonjs/quarks / packages/quarks/src / QuarkCommonProps
Interface: QuarkCommonProps<ElementType>
Type Parameters
ElementType
ElementType extends Element = HTMLElement
Properties
aria?
readonlyoptionalaria?:Readonly<Partial<Record<AriaAttributeName,QuarkAttributeValue>>>
children?
readonlyoptionalchildren?:TemplateValue
class?
readonlyoptionalclass?:ClassValue
className?
readonlyoptionalclassName?:ClassValue
data?
readonlyoptionaldata?:Readonly<Record<string,QuarkAttributeValue>>
dataset?
readonlyoptionaldataset?:Readonly<Record<string,QuarkAttributeValue>>
hidden?
readonlyoptionalhidden?:boolean
id?
readonlyoptionalid?:string
part?
readonlyoptionalpart?:string
ref?
readonlyoptionalref?:QuarkRef<ElementType>
role?
readonlyoptionalrole?:string
slot?
readonlyoptionalslot?:string
style?
readonlyoptionalstyle?:StyleValue
tabIndex?
readonlyoptionaltabIndex?:number
title?
readonlyoptionaltitle?:string
Example
Share typed children, class, style, semantics, ARIA, data, and ref bindings across every native-element Quark:
import { html } from '@gluonjs/core';
import {
fragment,
htmlTagNames,
q,
quark,
unsafeQuarkProps,
type AriaAttributeName,
type QuarkAriaProps,
type QuarkAttributeValue,
type QuarkCommonProps,
type QuarkDataProps,
type QuarkMap,
type QuarkProps,
type UnsafeQuarkProps,
} from '@gluonjs/quarks';
const ariaName: AriaAttributeName = 'label';
const attributeValue: QuarkAttributeValue = 'Add to bag';
const aria = { [ariaName]: attributeValue } satisfies QuarkAriaProps;
const data = { analyticsAction: 'purchase' } satisfies QuarkDataProps;
const common = { id: 'add-to-bag', class: 'primary' } satisfies QuarkCommonProps<HTMLButtonElement>;
const props = { ...common, type: 'button', aria, data, children: 'Add to bag' } satisfies QuarkProps<HTMLButtonElement>;
const future = unsafeQuarkProps<HTMLButtonElement>({ 'vendor-future-key': true });
const unsafe: UnsafeQuarkProps<HTMLButtonElement> = future;
const Button = quark('button');
const tags: QuarkMap = q;
const actions = fragment([Button(props), Button(unsafe), tags.a({ href: '/bag', children: html`View bag` })]);
console.log(Button.tagName, htmlTagNames.includes('button'), actions);