diff --git a/contents/_includes/patterns/radio-switch.njk b/contents/_includes/patterns/radio-switch.njk new file mode 100644 index 0000000..d317213 --- /dev/null +++ b/contents/_includes/patterns/radio-switch.njk @@ -0,0 +1,8 @@ +
+ + +
\ No newline at end of file diff --git a/contents/index.njk b/contents/index.njk index 5f4b27f..0820664 100644 --- a/contents/index.njk +++ b/contents/index.njk @@ -92,6 +92,7 @@ eleventyExcludeFromCollections: true {% pattern "Custom checkbox button" %}{% include "patterns/custom-checkbox-button.njk" %}{% endpattern %} {% pattern "Custom radio button" %}{% include "patterns/custom-radio-button.njk" %}{% endpattern %} {% pattern "Input addon" %}{% include "patterns/input-addon.njk" %}{% endpattern %} + {% pattern "Radio switch" %}{% include "patterns/radio-switch.njk" %}{% endpattern %} diff --git a/contents/radio-switch.md b/contents/radio-switch.md new file mode 100644 index 0000000..4c04ded --- /dev/null +++ b/contents/radio-switch.md @@ -0,0 +1,52 @@ +--- +layout: layouts/post.njk +title: Radio switch +description: Create a radio switch with CSS flexbox +keywords: css flexbox, css radio switch, css switch +--- + +## HTML + +```html +
+ + + + + ... +
+``` + +## CSS + +```css +.radio-switch { + background-color: #d1d5db; + border-radius: 9999px; + display: inline-flex; + padding: 0.25rem; +} + +.radio-switch__label { + border-radius: 9999px; + cursor: pointer; + padding: 0.25rem 0.5rem; +} + +.radio-switch__label--selected { + /* For selected radio only */ + background-color: #3b82f6; + color: #fff; +} + +.radio-switch__input { + display: none; +} +``` + +{% demo %}{% include "patterns/radio-switch.njk" %}{% enddemo %} diff --git a/pages/radio-switch/index.tsx b/pages/radio-switch/index.tsx deleted file mode 100644 index 1c50c8c..0000000 --- a/pages/radio-switch/index.tsx +++ /dev/null @@ -1,183 +0,0 @@ -import * as React from 'react'; -import Head from 'next/head'; -import { Heading, Spacer } from '@1milligram/design'; - -import { RelatedPatterns } from '../../components/RelatedPatterns'; -import { Pattern } from '../../constants/Pattern'; -import { PatternLayout } from '../../layouts/PatternLayout'; -import BrowserFrame from '../../placeholders/BrowserFrame'; - -const Details: React.FC<{}> = () => { - const [isFirstChecked, setFirstChecked] = React.useState(false); - const toggle = () => setFirstChecked((c) => !c); - - return ( - - - - - - - - -
- - - - - ... -
-`} - css={` - .container { - background-color: rgba(0, 0, 0, 0.1); - border-radius: 9999px; - display: inline-flex; - padding: 4px; - } - - .container__label { - border-radius: 9999px; - cursor: pointer; - padding: 4px 8px; - } - - .container__label--selected { - /* For selected radio only */ - background-color: #357edd; - color: #fff; - } - - .container__input { - display: none; - } - `} - > -
-
-