Search code examples
syntaxsvelte

semantics of svelte syntax greater then in `action={trigger}> {$open ? 'Close' : 'Open'}`


I came across this syntax from example in (MeltUI -- a svelte based component library

<Button on:click={() => console.log('clicked')} {...$trigger} action={trigger}>
  {$open ? 'Close' : 'Open'}
</Button>

I want to understand what does the > in action={trigger}> {$open ? 'Close' : 'Open'} used for?


Solution

  • It's just the end of the opening Button tag: <Button ... >

    Attribute Meaning
    on:click={() => console.log('clicked')} click event handler
    {...$trigger} spreading of multiple properties from store trigger
    action={trigger} action property being set to JS value trigger