Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 5 additions & 9 deletions core/src/components/cat-textarea/cat-textarea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,19 +282,15 @@ export class CatTextarea {
({i18n.t('input.required')})
</span>
)}
{(this.maxLength || this.hasSlottedCounter) && (
<div class="label-character-count" aria-hidden="true">
{this.hasSlottedCounter ? (
<slot name="counter"></slot>
) : (
`${this.value?.length ?? 0}/${this.maxLength}`
)}
</div>
)}
</div>
</span>
</label>
)}
{(this.maxLength || this.hasSlottedCounter) && (
<div class="character-count" aria-atomic="true" aria-live="polite">
{this.hasSlottedCounter ? <slot name="counter"></slot> : `${this.value?.length ?? 0}/${this.maxLength}`}
</div>
)}
</div>
<div class="textarea-container">
<div
Expand Down
2 changes: 2 additions & 0 deletions core/src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1310,6 +1310,8 @@ <h3>Slotted Counter</h3>
<cat-textarea label="Custom counter">
<span slot="counter">Show any text here</span>
</cat-textarea>
<h3>Counter w/o label</h3>
<cat-textarea max-length="100"></cat-textarea>
</section>

<section id="toggle" class="cat-form">
Expand Down
11 changes: 7 additions & 4 deletions core/src/styles/_snippets/_form-label.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ $cat-input-height: 2.5rem;
flex-basis: var(--label-size, 33.33%);
}

.label-wrapper {
.label-wrapper,
.label-container {
display: flex;
gap: 0.25rem;
}
Expand All @@ -35,15 +36,17 @@ $cat-input-height: 2.5rem;
}

.label-optional,
.label-character-count {
.character-count {
display: inline-flex;
align-items: center;
max-height: 1.25rem;
@include cat-body('xs', null);
}

.label-character-count {
.character-count {
margin-left: auto;
flex-shrink: 0;
color: cat-token('color.ui.font.muted');
}

.input-horizontal,
Expand All @@ -70,7 +73,7 @@ $cat-input-height: 2.5rem;
.label-metadata {
justify-content: flex-start;

.label-character-count {
.character-count {
margin-left: 0;
}
}
Expand Down
Loading