Skip to main content
Create new
Introduction
Reactivity
Props
Logic
Events
Bindings
Lifecycle
Stores
Motion
Transitions
Animations
Easing
SVG
Actions
Classes
Component composition
Context API
Special elements
Module context
Debugging
7GUIs
Miscellaneous
App.svelte
<script>
import { fade } from 'svelte/transition';
let visible = $state(true);
</script>

<label>
<input type="checkbox" bind:checked={visible} />
visible
</label>

{#if visible}
<p transition:fade>Fades in and out</p>
{/if}

Error compiling component

WebAssembly.instantiateStreaming(): value type opcode @+13
import 'svelte/internal/disclose-version';
import * as $ from 'svelte/internal/client';
import { fade } from 'svelte/transition';

var root_1 = $.template(`<p>Fades in and out</p>`);
var root = $.template(`<label><input type="checkbox"> visible</label> <!>`, 1);

export default function App($$anchor) {
let visible = $.state(true);
var fragment = root();
var label = $.first_child(fragment);
var input = $.child(label);

$.remove_input_defaults(input);
$.next();
$.reset(label);

var node = $.sibling(label, 2);

{
var consequent = ($$anchor) => {
var p = root_1();

$.transition(3, p, () => fade);
$.append($$anchor, p);
};

$.if(node, ($$render) => {
if ($.get(visible)) $$render(consequent);
});
}

$.bind_checked(input, () => $.get(visible), ($$value) => $.set(visible, $$value));
$.append($$anchor, fragment);
}
result = svelte.compile(source, {
generate: ,
});
/* Add a <style> tag to see the CSS output */
		
			
				
  • Root {
    • css: null
    • js: []
    • start: 92
    • end: 229
    • type: "Root"
    • fragment: Fragment {...}
      • type: "Fragment"
      • nodes: [...] (4)
        • Text {...}
          • type: "Text"
          • start: 90
          • end: 92
          • raw: "\n\n"
          • data: "\n\n"
          }
        • RegularElement {...}
          • type: "RegularElement"
          • start: 92
          • end: 167
          • name: "label"
          • attributes: []
          • fragment: Fragment {...}
            • type: "Fragment"
            • nodes: [...] (3)
              • Text {...}
                • type: "Text"
                • start: 99
                • end: 101
                • raw: "\n\t"
                • data: "\n\t"
                }
              • RegularElement {...}
                • type: "RegularElement"
                • start: 101
                • end: 149
                • name: "input"
                • attributes: [...] (2)
                  • Attribute {...}
                    • type: "Attribute"
                    • start: 108
                    • end: 123
                    • name: "type"
                    • value: [...] (1)
                      • Text {...}
                        • start: 114
                        • end: 122
                        • type: "Text"
                        • raw: "checkbox"
                        • data: "checkbox"
                        }
                      ]
                    }
                  • BindDirective {...}
                    • start: 124
                    • end: 146
                    • type: "BindDirective"
                    • name: "checked"
                    • expression: Identifier {...}
                      • type: "Identifier"
                      • start: 138
                      • end: 145
                      • loc: {...}
                        • start: {...}
                          • line: 7
                          • column: 38
                          }
                        • end: {...}
                          • line: 7
                          • column: 45
                          }
                        }
                      • name: "visible"
                      }
                    • modifiers: []
                    }
                  ]
                • fragment: Fragment {...}
                  • type: "Fragment"
                  • nodes: []
                  }
                }
              • Text {...}
                • type: "Text"
                • start: 149
                • end: 159
                • raw: " visible"
                • data: " visible"
                }
              ]
            }
          }
        • Text {...}
          • type: "Text"
          • start: 167
          • end: 169
          • raw: " "
          • data: " "
          }
        • IfBlock {...}
          • type: "IfBlock"
          • elseif: false
          • start: 169
          • end: 229
          • test: Identifier {...}
            • type: "Identifier"
            • start: 174
            • end: 181
            • loc: {...}
              • start: {...}
                • line: 11
                • column: 5
                }
              • end: {...}
                • line: 11
                • column: 12
                }
              }
            • name: "visible"
            }
          • consequent: Fragment {...}
            • type: "Fragment"
            • nodes: [...] (3)
              • Text {...}
                • type: "Text"
                • start: 182
                • end: 184
                • raw: "\n\t"
                • data: "\n\t"
                }
              • RegularElement {...}
                • type: "RegularElement"
                • start: 184
                • end: 223
                • name: "p"
                • attributes: [...] (1)
                  • TransitionDirective {...}
                    • start: 187
                    • end: 202
                    • type: "TransitionDirective"
                    • name: "fade"
                    • expression: null
                    • modifiers: []
                    • intro: true
                    • outro: true
                    }
                  ]
                • fragment: Fragment {...}
                  • type: "Fragment"
                  • nodes: [...] (1)
                    • Text {...}
                      • type: "Text"
                      • start: 203
                      • end: 219
                      • raw: "Fades in and out"
                      • data: "Fades in and out"
                      }
                    ]
                  }
                }
              • Text {...}
                • type: "Text"
                • start: 223
                • end: 224
                • raw: "\n"
                • data: "\n"
                }
              ]
            }
          • alternate: null
          }
        ]
      }
    • options: null
    • instance: Script {...}
      • type: "Script"
      • start: 0
      • end: 90
      • context: "default"
      • content: Program {...}
        • type: "Program"
        • start: 8
        • end: 81
        • loc: {...}
          • start: {...}
            • line: 1
            • column: 0
            }
          • end: {...}
            • line: 4
            • column: 0
            }
          }
        • body: [...] (2)
          • ImportDeclaration {...}
            • type: "ImportDeclaration"
            • start: 10
            • end: 51
            • loc: {...}
              • start: {...}
                • line: 2
                • column: 1
                }
              • end: {...}
                • line: 2
                • column: 42
                }
              }
            • specifiers: [...] (1)
              • ImportSpecifier {...}
                • type: "ImportSpecifier"
                • start: 19
                • end: 23
                • loc: {...}
                  • start: {...}
                    • line: 2
                    • column: 10
                    }
                  • end: {...}
                    • line: 2
                    • column: 14
                    }
                  }
                • imported: Identifier {...}
                  • type: "Identifier"
                  • start: 19
                  • end: 23
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 10
                      }
                    • end: {...}
                      • line: 2
                      • column: 14
                      }
                    }
                  • name: "fade"
                  }
                • local: Identifier {...}
                  • type: "Identifier"
                  • start: 19
                  • end: 23
                  • loc: {...}
                    • start: {...}
                      • line: 2
                      • column: 10
                      }
                    • end: {...}
                      • line: 2
                      • column: 14
                      }
                    }
                  • name: "fade"
                  }
                }
              ]
            • source: Literal {...}
              • type: "Literal"
              • start: 31
              • end: 50
              • loc: {...}
                • start: {...}
                  • line: 2
                  • column: 22
                  }
                • end: {...}
                  • line: 2
                  • column: 41
                  }
                }
              • value: "svelte/transition"
              • raw: "'svelte/transition'"
              }
            }
          • VariableDeclaration {...}
            • type: "VariableDeclaration"
            • start: 53
            • end: 80
            • loc: {...}
              • start: {...}
                • line: 3
                • column: 1
                }
              • end: {...}
                • line: 3
                • column: 28
                }
              }
            • declarations: [...] (1)
              • VariableDeclarator {...}
                • type: "VariableDeclarator"
                • start: 57
                • end: 79
                • loc: {...}
                  • start: {...}
                    • line: 3
                    • column: 5
                    }
                  • end: {...}
                    • line: 3
                    • column: 27
                    }
                  }
                • id: Identifier {...}
                  • type: "Identifier"
                  • start: 57
                  • end: 64
                  • loc: {...}
                    • start: {...}
                      • line: 3
                      • column: 5
                      }
                    • end: {...}
                      • line: 3
                      • column: 12
                      }
                    }
                  • name: "visible"
                  }
                • init: CallExpression {...}
                  • type: "CallExpression"
                  • start: 67
                  • end: 79
                  • loc: {...}
                    • start: {...}
                      • line: 3
                      • column: 15
                      }
                    • end: {...}
                      • line: 3
                      • column: 27
                      }
                    }
                  • callee: Identifier {...}
                    • type: "Identifier"
                    • start: 67
                    • end: 73
                    • loc: {...}
                      • start: {...}
                        • line: 3
                        • column: 15
                        }
                      • end: {...}
                        • line: 3
                        • column: 21
                        }
                      }
                    • name: "$state"
                    }
                  • arguments: [...] (1)
                    • Literal {...}
                      • type: "Literal"
                      • start: 74
                      • end: 78
                      • loc: {...}
                        • start: {...}
                          • line: 3
                          • column: 22
                          }
                        • end: {...}
                          • line: 3
                          • column: 26
                          }
                        }
                      • value: true
                      • raw: "true"
                      }
                    ]
                  • optional: false
                  }
                }
              ]
            • kind: "let"
            }
          ]
        • sourceType: "module"
        }
      • attributes: []
      }
    }
The AST is not public API and may change at any point in time
The transition directive • Playground • Svelte