Skip to content
Merged
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
121 changes: 121 additions & 0 deletions css/mistica-common.css
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,127 @@
}
}

/* Chip */

.mistica-chip {
font-weight: var(--mistica-font-weight-indicator);
font-size: var(--mistica-font-size-2);
line-height: var(--mistica-line-height-2);
color: var(--mistica-color-textPrimary);
border: 1px solid var(--mistica-color-control);
border-radius: var(--mistica-border-radius-indicator);
background: var(--mistica-color-backgroundContainer);
position: relative;
overflow: hidden;
min-width: 72px;
min-height: 40px;
padding: 0 20px;
display: inline-flex;
align-items: center;
justify-content: center;
text-decoration: none;
}
label.mistica-chip {
padding: 0;
border: none;
overflow: visible;
background: transparent;
}
label.mistica-chip > span {
border: 1px solid var(--mistica-color-control);
border-radius: var(--mistica-border-radius-indicator);
background: var(--mistica-color-backgroundContainer);
position: relative;
overflow: hidden;
min-width: 72px;
min-height: 40px;
padding: 0 20px;
display: flex;
align-items: center;
}

@media (min-width: 1024px) {
.mistica-chip,
label.mistica-chip > span {
min-width: 56px;
min-height: 32px;
padding: 0 12px;
}
}

button.mistica-chip,
a.mistica-chip,
label.mistica-chip {
cursor: pointer;
user-select: none;
}

button.mistica-chip:before,
a.mistica-chip:before,
label.mistica-chip > span:before {
position: absolute;
content: '';
top: 0;
left: 0;
width: 100%;
height: 100%;
background: transparent;
transition: background-color 0.1s ease-in-out;
}

button.mistica-chip:hover:before,
a.mistica-chip:hover:before,
label.mistica-chip > input:hover + span:before {
background: var(--mistica-color-backgroundContainerHover);
}

button.mistica-chip:active:before,
a.mistica-chip:active:before,
label.mistica-chip > input:active + span:before {
background: var(--mistica-color-backgroundContainerPressed);
}

label.mistica-chip > input {
appearance: none;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
margin: 0;
padding: 0;
border-radius: var(--mistica-border-radius-indicator);
outline-offset: 0;
}

label.mistica-chip > input:checked + span {
color: var(--mistica-color-textActivated);
background: var(--mistica-color-brandLow);
border-color: var(--mistica-color-controlActivated);
}

.mistica-chip > button {
display: flex;
align-items: center;
justify-content: center;
background: transparent;
border: none;
color: inherit;
font: inherit;
cursor: pointer;
padding: 0;
margin: 0;
min-width: 24px;
min-height: 24px;
margin-left: 4px;
margin-right: -4px;
}

.mistica-chip > button > svg {
width: 1rem;
height: 1rem;
}

/* Tag */
[class^='mistica-tag'] {
font-weight: var(--mistica-font-weight-indicator);
Expand Down
25 changes: 25 additions & 0 deletions examples/css/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,31 @@ <h3 class="mistica-text-title2">Tag</h3>
<div class="mistica-tag-error">Error</div>
</div>

<h3 class="mistica-text-title2">Chip</h3>
<div>
<button class="mistica-chip">Chip button</button>
<a href="#" class="mistica-chip">Chip a</a>
<label class="mistica-chip"><input type="checkbox" /><span>Chip checkbox</span></label>

@atabel atabel Apr 21, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the span for the label text is needed in this case to be able to change the label styles depending on the sibling checkbox state (:active :checked, etc) input:checked + span

I could avoid the span using :has() to style the label with something like label:has(input:checked), but has() doesn't have enough browser support

<span class="mistica-chip"
>Chip closable<button aria-label="cerrar">
<svg viewBox="0 0 24 24">
<path
fill="currentColor"
d="M16.841 17.853a.722.722 0 0 0 .948-1.086L13.022 12l4.766-4.767.065-.074a.722.722 0 0 0-1.086-.947L12 10.978 7.233 6.211l-.074-.064a.722.722 0 0 0-.947 1.086L10.979 12 6.21 16.767l-.064.074a.722.722 0 0 0 1.086.947L12 13.022l4.767 4.767z"
/>
</svg></button
></span>
<label class="mistica-chip"
><input type="radio" name="chip-radio-example" /><span>Chip radio 1</span></label
>
<label class="mistica-chip"
><input type="radio" name="chip-radio-example" /><span>Chip radio 2</span></label
>
<label class="mistica-chip"
><input type="radio" name="chip-radio-example" /><span>Chip radio 3</span></label
>
</div>

<h3 class="mistica-text-title2">Buttons</h3>
<div>
<a class="mistica-button-primary" href="#">Primary</a>
Expand Down