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
9 changes: 9 additions & 0 deletions Checkbox.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import { sineInOut } from "svelte/easing";
import { createStyle } from "./utils";


export let disabled = false;

let self,
canChange = true,
changeBg = false,
Expand Down Expand Up @@ -136,6 +139,11 @@
--checkbox-border-width: var(--checkbox-border-width-active);
stroke: var(--checkbox-color-primary);
}

.checkbox__disabled {
pointer-events: none;
opacity: 0.6;
}
</style>

<div
Expand All @@ -144,6 +152,7 @@
class="checkbox {$$props.class}"
class:-changeBg={changeBg}
class:-checked={checked || !canChange}
class:disabled={disabled}
style="width: {size};height: {size};">
<input id={labelId} type="checkbox" on:change={handleChange} {name} />
<svg class="checkbox__svg" preserveAspectRatio="none" viewBox="0 0 100 100">
Expand Down
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ yarn add svelte-checkbox
| primaryColor | String | #242432 | Primary color |
| secondaryColor | String | #d8d8ea | Secondary color |
| checked | Boolean | false | Checked input |
| disabled | Boolean | false | disabled input |

<br />

Expand All @@ -64,6 +65,16 @@ yarn add svelte-checkbox

<br />

## Disabled checkbox example
```html
<script>
import Checkbox from "svelte-checkbox";
</script>

<Checkbox disabled />
```
<br />

## Full Usage

```html
Expand Down