Character count
A character count displays the current and maximum number of characters allowed in a text input or textarea.
Examples
<!-- live-example -->
<script>
export default {
inputId: 'form-input-with-character-count',
countTextId: 'character-count-text',
limit: 100,
data() {
return {
value: '',
}
},
methods: {
remainingCountText(count) {
return `${count} characters remaining.`;
},
overLimitText(count) {
return `${count} characters over limit.`;
},
},
};
</script>
<template>
<gl-form-group label="Form input with character count" :label-for="$options.inputId">
<gl-form-input
v-model="value"
:id="$options.inputId"
:value="value"
:aria-describedby="$options.countTextId"
/>
<gl-form-character-count
:value="value"
:limit="$options.limit"
:count-text-id="$options.countTextId"
>
<template #remaining-count-text="{ count }">{{ remainingCountText(count) }}</template>
<template #over-limit-text="{ count }">{{ overLimitText(count) }}</template>
</gl-form-character-count>
</gl-form-group>
</template>
Structure
TODO:
Add structure image.
Create an issue
Guidelines
TODO:
Add guidelines.
Create an issue
Appearance
TODO:
Add appearance.
Create an issue
Behavior
TODO:
Add behavior.
Create an issue
Accessibility
TODO:
Add accessibility.
Create an issue
Code reference
GlFormCharacterCount
GlFormCharacterCount can be used to add a character count to an input.
If you are using GlFormTextarea on its own see with character count example.
If you are wrapping your input, such as in a markdown component, and need the character
count separate from the input, use GlFormCharacterCount.
Loading story...
Last updated at: