StringifiedBooleanConverter
ts
const StringifiedBooleanConverter: ConverterFactory<boolean, [string?, string?]>;
Converts a boolean property to a stringified representation. For example setting boolean WAI-ARIA attributes, which are usually set to true
or false
as string, can not be used as boolean attributes directly in Lit. To handle this, you can use the StringifiedBooleanConverter
provided by this package, which allows you to map a boolean value to its string representation.
See
https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-expanded#values
Param
The string representation for true
(default: 'true').
Param
The string representation for false
(default: 'false').
Example
typescript
class MyDropdown extends LitElement {
@property({
type: Boolean,
reflect: true,
attribute: 'aria-expanded',
converter: StringifiedBooleanConverter('true', 'false'),
})
active = false;
}