Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@lion/input
Advanced tools
lion-input
component is a webcomponent that enhances the functionality of the native <input>
element.
import { html } from '@lion/core';
import './lion-input.js';
export default {
title: 'Forms/Input',
};
export const main = () => html` <lion-input label="First Name"></lion-input> `;
slots
label
attribute, but the slot can be used to change the html
and CSS
of the label.
For example add an u-sr-only
class to the label to make it visually hidden.
A label is always needed for accessibility reasons.type
, disabled
, placeholder
and read-only
to the native input.npm i --save @lion/input
import '@lion/input/lion-input.js';
Can be provided via the label
attribute, but the slot can be used to change the html
and CSS
of the label.
For example add an u-sr-only
class to the label to make it (partially) visually hidden.
A label is always needed for accessibility reasons.
export const label = () => html`
<style>
.u-sr-only {
position: absolute;
top: 0;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(100%);
clip: rect(1px, 1px, 1px, 1px);
white-space: nowrap;
border: 0;
margin: 0;
padding: 0;
}
</style>
<lion-input>
<label slot="label"
>Label <span class="u-sr-only">partially only visible for screen-readers</span></label
>
</lion-input>
`;
A helper text shown below the label to give extra clarification.
Just like the label
, a help-text
can be provided via the help-text
attribute, a slot can be used to change the html
and CSS
of the help-text.
For example add an anchor with further explanation.
export const helpText = () => html`
<lion-input>
<label slot="label">Label</label>
<div slot="help-text">
Help text using <a href="https://example.com/" target="_blank">html</a>
</div>
</lion-input>
`;
export const prefilled = () => html`
<lion-input .modelValue=${'Prefilled value'} label="Prefilled"></lion-input>
`;
readonly
attribute will be delegated to the native <input>
to make it read-only.
This field will still be included in the parent fieldset or form's serializedValue
.
export const readOnly = () => html`
<lion-input readonly .modelValue=${'This is read only'} label="Read only"></lion-input>
`;
disabled
attribute will be delegated to the native <input>
to make it disabled.
This field will not be included in the parent fieldset or form's serializedValue
.
export const disabled = () => html`
<lion-input disabled .modelValue=${'This is disabled'} label="Disabled"></lion-input>
`;
Prefix slot does not have an active use case yet.
export const prefix = () => html`
<lion-input label="Prefix">
<div slot="prefix">[prefix]</div>
</lion-input>
`;
The suffix can be used for addons to the input like a calculator, datepicker or addressbook. In these cases a button with an icon is used.
export const suffix = () => html`
<lion-input label="Suffix">
<div slot="suffix">[suffix]</div>
</lion-input>
`;
Before slot does not have an active use case yet.
export const before = () => html`
<lion-input label="Before">
<div slot="before">[before]</div>
</lion-input>
`;
export const after = () => html`
<lion-input label="Amount">
<div slot="after">EUR</div>
</lion-input>
<lion-input label="Percentage">
<div slot="after">%</div>
</lion-input>
`;
FAQs
It enhances the functionality of the native `` element
The npm package @lion/input receives a total of 1,246 weekly downloads. As such, @lion/input popularity was classified as popular.
We found that @lion/input demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.