Button:

Right and Left Keyboard to navigate :)

This is currently a work in progress...Check back soon! :)


# Button
<Button onClick$={$(() => { alert('clicked');})}
  color='neutral'
  type='button'
  variant='normal'
>
  This is a button
</Button>
import { Slot, component$ } from '@builder.io/qwik';
import type { ClassList, Component, PropFunction } from '@builder.io/qwik';
                  
                  export interface ButtonProps {
                    onClick$?: PropFunction<() => void>,
                    disabled?: boolean,
                    type?: 'submit' | 'reset' | 'button',
                    color?: 'primary' | 'secondary' | 'accent' | 'neutral' | 'info' | 'success' | 'warning' | 'error',
                    variant?: 'link' | 'ghost' | 'outline' | 'normal',
                    size?: 'xs' | 'sm' | 'md' | 'lg' | 'wide' | 'block' | 'responsive',
                    active?: boolean,
                    shape?: 'circle' | 'square',
                    loadingStart?: boolean,
                    loadingEnd?: boolean,
                    class?: ClassList,
                    As?: 'Link' | "",
                    href?: string
                  }
                  
                  export const Button = component$<ButtonProps>((props) => {
                  
                    if (props.As === 'Link' && !props.href) {
                      throw new Error("href is required when As is set to 'Link'");
                    }
                  
                    return (
                      <button class={`
                      btn ${props.color == 'primary' ? 'btn-primary' :
                          props.color == 'secondary' ? 'btn-secondary' :
                            props.color == 'accent' ? 'btn-accent' :
                              props.color == 'neutral' ? 'btn-neutral' :
                                props.color == 'info' ? 'btn-info' :
                                  props.color == 'success' ? 'btn-success' :
                                    props.color == 'warning' ? 'btn-warning' :
                                      props.color == 'error' ? 'btn-error' :
                                        'btn-primary'}
                      ${props.active ? 'btn-active' : ''}
                      ${props.variant == 'link' ? 'btn-link' :
                          props.variant == 'ghost' ?
                            props.color == "primary" ? 'btn-ghost hover:bg-primary hover:bg-opacity-70 text-primary hover:text-base-content' :
                              props.color == "secondary" ? 'btn-ghost hover:bg-secondary hover:bg-opacity-70 text-secondary hover:text-base-content' :
                                props.color == "accent" ? 'btn-ghost hover:bg-accent hover:bg-opacity-70 hover:text-base-200 text-accent' :
                                  props.color == "neutral" ? 'btn-ghost hover:bg-neutral hover:bg-opacity-70 ' :
                                    props.color == "info" ? 'btn-ghost hover:bg-info hover:bg-opacity-70 hover:text-base-200 text-info' :
                                      props.color == "success" ? 'btn-ghost hover:bg-success hover:bg-opacity-70 hover:text-base-200 text-success' :
                                        props.color == "warning" ? 'btn-ghost hover:bg-warning hover:bg-opacity-70 hover:text-base-200 text-warning' :
                                          props.color == "error" ? 'btn-ghost hover:bg-error hover:bg-opacity-70 hover:text-base-200 text-error' :
                                            'btn-ghost hover:btn-primary hover:bg-opacity-70 text-primary hover:text-base-content'
                            :
                            props.variant == 'outline' ? 'btn-outline' :
                              'btn-normal'}
                      ${props.shape == 'circle' ? 'btn-circle' :
                          props.shape == 'square' ? 'btn-square' :
                            ''}
                      ${props.class}
                      ${props.disabled ? 'btn-disabled' : ''}
                      ${props.As == 'Link' ? 'pr-0 pl-0' : ''}
                      ${props.size == 'xs' ? 'btn-xs' :
                          props.size == 'sm' ? 'btn-sm' :
                            props.size == 'md' ? 'btn-md' :
                              props.size == 'lg' ? 'btn-lg' :
                                props.size == 'wide' ? 'btn-wide' :
                                  props.size == 'block' ? 'btn-block' :
                                    props.size == 'responsive' ? 'btn-xs sm:btn-sm md:btn-md lg:btn-lg' :
                                      'btn-md'}
                      `}
                        type={props.type}
                        onClick$={props.onClick$}
                        disabled={props.disabled}
                      >
                        {props.loadingStart == true ? <span class="loading loading-spinner"></span> : null}
                        {props.As == 'Link' ? <a href={props.href} class="pr-6 pl-6 h-full text-center flex align-middle justify-center items-center"><Slot /></a> : <Slot />}
                        {props.loadingEnd == true ? <span class="loading loading-spinner"></span> : null}
                      </button>
                    );
                  });
                  
# Button Colors
<Button color='neutral' type='button' variant='normal'>
  Neutral
</Button>
<Button color='accent' type='button' variant='normal'>
  Accent
</Button>
<Button color='info' type='button' variant='normal'>
  Info
</Button>
<Button color='primary' type='button' variant='normal'>
  Primary
</Button>
<Button color='secondary' type='button' variant='normal'>
  Secondary
</Button>
<Button color='warning' type='button' variant='normal'>
  Warning
</Button>
<Button color='error' type='button' variant='normal'>
  Error
</Button>
<Button color='success' type='button' variant='normal'>
  Success
</Button>
# Outline Buttons
<Button color='neutral' type='button' variant='outline'>
  Neutral
</Button>
<Button color='accent' type='button' variant='outline'>
  Accent
</Button>
<Button color='info' type='button' variant='outline'>
  Info
</Button>
<Button color='primary' type='button' variant='outline'>
  Primary
</Button>
<Button color='secondary' type='button' variant='outline'>
  Secondary
</Button>
<Button color='warning' type='button' variant='outline'>
  Warning
</Button>
<Button color='error' type='button' variant='outline'>
  Error
</Button>
<Button color='success' type='button' variant='outline'>
  Success
</Button>
# Ghost Buttons
<Button color='neutral' type='button' variant='ghost'>
  Neutral
</Button>
<Button color='accent' type='button' variant='ghost'>
  Accent
</Button>
<Button color='info' type='button' variant='ghost'>
  Info
</Button>
<Button color='primary' type='button' variant='ghost'>
  Primary
</Button>
<Button color='secondary' type='button' variant='ghost'>
  Secondary
</Button>
<Button color='warning' type='button' variant='ghost'>
  Warning
</Button>
<Button color='error' type='button' variant='ghost'>
  Error
</Button>
<Button color='success' type='button' variant='ghost'>
  Success
</Button>

Setting variant to 'link' will only style the button as a link.
To make it a link, you must set the href prop and the As prop

<Button color='neutral' variant='link'>
  Styled Link to nothing
</Button>
<Button variant='normal' As='Link' href='/docs/button'>
  Normal Styling to docs/button
</Button>
<Button variant='link' As='Link' href='/docs/button'>
  Styled Link to docs/button
</Button>
# Active Buttons

Active means reducing hover/interactivity effects

<Button color='neutral' type='button' variant='normal' active>
  Normal Active
</Button>
<Button color='accent' type='button' variant='ghost' active>
  Ghost Active
</Button>
<Button color='info' type='button' variant='ghost' active>
  Ghost Active
</Button>
<Button color='primary' type='button' variant='outline' active>
  Outline Active
</Button>
<Button color='secondary' type='button' variant='link' active>
  Link Active
</Button>
<Button color='warning' type='button' variant='normal' active>
  Normal Active
</Button>
<Button color='error' type='button' variant='normal' active>
  Normal Active
</Button>
<Button color='success' type='button' variant='outline' active>
  Outline Active
</Button>
# Button Sizes
<Button color='primary' type='button' variant='normal' size='xs'>
  Extra Small
</Button>
<Button color='primary' type='button' variant='normal' size='sm'>
  Small
</Button>
<Button color='primary' type='button' variant='normal' size='md'>
  Medium
</Button>
<Button color='primary' type='button' variant='normal' size='lg'>
  Large
</Button>
<Button color='primary' type='button' variant='normal' size='wide'>
  Wide
</Button>
<Button color='primary' type='button' variant='normal' size='block'>
  Block
</Button>
<Button color='primary' type='button' variant='normal' size='responsive'>
  Responsive
</Button>
# Disabled Buttons
<Button color='primary' type='button' variant='outline'  disabled>
  I am disabled
</Button>
<Button color='primary' type='button' variant='normal'  disabled>
  I am disabled
</Button>
# Button Icons

You can simply add a icon to the button before or after your child text.

<Button color='primary' type='button' >
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z" /></svg>
Icon Start
</Button>
<Button color='primary' type='button' >
Icon End
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z" /></svg>
</Button>
# Button Shapes
<Button color='primary' type='button' shape='circle'>
  <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" /></svg>
</Button>
<Button color='primary' type='button' shape='circle' variant='outline'>
  <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" /></svg>
</Button>
<Button color='primary' type='button' shape='square'>
  <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" /></svg>
</Button>
<Button color='primary' variant='outline' shape='square'>
  <svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12" /></svg>
</Button>
# Button Loading

You can use the props for loadingStart and loadingEnd.
Or.. You can use your own loader by putting before or after your child text.

<Button color='primary' type='button' loadingStart >
  Loading Start
</Button>
<Button color='primary' type='button' loadingEnd >
  Loading End
</Button>
<Button color='primary' type='button' loadingStart shape='square'></Button>
<Button color='primary' type='button' loadingStart shape='circle' variant='outline'></Button>
<Button color='primary' type='button' >
  <span class="loading loading-spinner"></span>
  No Props
</Button>
# Custom Button Styles

Class allows you to use your own custom tailwind class styles on top of the button component.
For example: you can add shadow and hover effects.

<Button color='primary' type='button' variant='outline' size='lg' class='shadow-md hover:shadow-2xl shadow-primary hover:shadow-red-600 hover:scale-125 hover:bg-gradient-to-tr from-[#55074e]  to-[#FE9A03] hover:animate-none animate-pulse'>
   Custom Tailwind Styles
</Button>