Skip to content

Commit

Permalink
Added new examples for switch components (React, Vue) (#245)
Browse files Browse the repository at this point in the history
* Added new example for switch component (React)

* Added new example for switch component (Vue)
  • Loading branch information
alexanderbluhm authored and RobinMalfait committed Mar 26, 2021
1 parent f312513 commit b4c0ded
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions packages/@headlessui-react/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1286,12 +1286,12 @@ function NotificationsToggle() {
onChange={setEnabled}
className={`${
enabled ? 'bg-blue-600' : 'bg-gray-200'
} relative inline-flex h-6 rounded-full w-8`}
} relative inline-flex items-center h-6 rounded-full w-11`}
>
<span className="sr-only">Enable notifications</span>
<span
className={`${
enabled ? 'translate-x-4' : 'translate-x-0'
enabled ? 'translate-x-6' : 'translate-x-1'
} inline-block w-4 h-4 transform bg-white rounded-full`}
/>
</Switch>
Expand Down Expand Up @@ -1320,11 +1320,11 @@ function NotificationsToggle() {
onChange={setEnabled}
className={`${
enabled ? 'bg-blue-600' : 'bg-gray-200'
} relative inline-flex h-6 rounded-full w-8`}
} relative inline-flex items-center h-6 rounded-full w-11`}
>
<span
className={`${
enabled ? 'translate-x-4' : 'translate-x-0'
enabled ? 'translate-x-6' : 'translate-x-1'
} inline-block w-4 h-4 transform bg-white rounded-full`}
/>
</Switch>
Expand Down
8 changes: 4 additions & 4 deletions packages/@headlessui-vue/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1093,13 +1093,13 @@ Switches are built using the `Switch` component. Optionally you can also use the
<Switch
as="button"
v-model="switchValue"
class="relative inline-flex w-8 h-6 rounded-full"
class="relative inline-flex items-center h-6 rounded-full w-11"
:class="switchValue ? 'bg-blue-600' : 'bg-gray-200'"
v-slot="{ checked }"
>
<span
class="inline-block w-4 h-4 transform bg-white rounded-full"
:class="{ 'translate-x-5': checked, 'translate-x-0': !checked }"
:class="{ 'translate-x-6': checked, 'translate-x-1': !checked }"
/>
</Switch>
</template>
Expand Down Expand Up @@ -1140,13 +1140,13 @@ Clicking the label will toggle the switch state, like you'd expect from a native
<Switch
as="button"
v-model="switchValue"
class="relative inline-flex w-8 h-6 rounded-full"
class="relative inline-flex items-center h-6 rounded-full w-11"
:class="switchValue ? 'bg-blue-600' : 'bg-gray-200'"
v-slot="{ checked }"
>
<span
class="inline-block w-4 h-4 transform bg-white rounded-full"
:class="{ 'translate-x-5': checked, 'translate-x-0': !checked }"
:class="{ 'translate-x-6': checked, 'translate-x-1': !checked }"
/>
</Switch>
</SwitchGroup>
Expand Down

0 comments on commit b4c0ded

Please sign in to comment.