File upload

The b.File constructor creates a file input.

ModifierAction
b.RightMove the call-to-action to the right side, align the file input to the right
b.FullWidthExpand the name to fill up the space
b.BoxedMake the input a boxed block
b.CenteredAlight the file input to the center
b.WhiteSet color to white
b.BlackSet color to black
b.LightSet color to light
b.DarkSet color to dark
b.PrimarySet color to primary
b.LinkSet color to link
b.InfoSet color to info
b.SuccessSet color to success
b.WarningSet color to warning
b.DangerSet color to danger
b.SmallSet size to small
b.NormalSet size to normal
b.MediumSet size to medium
b.LargeSet size to large
ChildAction
b.OnCTA(...any)Apply children to the <span class="file-cta"> element
b.OnDiv(...any)Apply children to the <div class="file"> element
b.OnInput(...any)Apply children to the <input> element
stringDefine the call-to-action label
b.FileNameDefine the content of the <span class="file-name"> element
b.FileNameAutoUpdateDefine the content of the <span class="file-name"> element, which changes when a file is selected
e.ElementAdd element to the <span class="file-cta"> element
Anything elseApply child to the <input> element

Bulma examples

Example
Code
b.File(
	e.Name("resume"),
	fa.Icon(fa.Solid, "upload"),
	"Choose a file…",
)
ResultHTML

Modifiers

Example
Code
b.File(
	e.Name("resume"),
	fa.Icon(fa.Solid, "upload"),
	"Choose a file…",
	b.FileName("Screen Shot 2017-07-29 at 15.54.25.png"),
)
ResultHTML
Example
Code
b.File(
	e.Name("resume"),
	b.Right,
	fa.Icon(fa.Solid, "upload"),
	"Choose a file…",
	b.FileName("Screen Shot 2017-07-29 at 15.54.25.png"),
)
ResultHTML
Example
ResultHTML
Code
b.File(
	e.Name("resume"),
	b.FullWidth,
	fa.Icon(fa.Solid, "upload"),
	"Choose a file…",
	b.FileName("Screen Shot 2017-07-29 at 15.54.25.png"),
)
Example
Code
b.File(
	e.Name("resume"),
	b.Boxed,
	fa.Icon(fa.Solid, "upload"),
	"Choose a file…",
)
ResultHTML
Example
Code
b.File(
	e.Name("resume"),
	b.Boxed,
	fa.Icon(fa.Solid, "upload"),
	"Choose a file…",
	b.FileName("Screen Shot 2017-07-29 at 15.54.25.png"),
)
ResultHTML

Colors

Example
Code
b.File(
	e.Name("resume"),
	b.Primary,
	fa.Icon(fa.Solid, "upload"),
	"Primary file…",
)
ResultHTML
Example
Code
b.File(
	e.Name("resume"),
	b.Info,
	fa.Icon(fa.Solid, "upload"),
	"Info file…",
	b.FileName("Screen Shot 2017-07-29 at 15.54.25.png"),
)
ResultHTML
Example
Code
b.File(
	e.Name("resume"),
	b.Warning,
	b.Boxed,
	fa.Icon(fa.Solid, "upload"),
	"Warning file…",
)
ResultHTML
Example
Code
b.File(
	e.Name("resume"),
	b.Danger,
	b.Boxed,
	fa.Icon(fa.Solid, "upload"),
	"Danger file…",
	b.FileName("Screen Shot 2017-07-29 at 15.54.25.png"),
)
ResultHTML

Sizes

Example
Code
b.File(
	e.Name("resume"),
	b.Small,
	fa.Icon(fa.Solid, "upload"),
	"Small file…",
)
ResultHTML
Example
Code
b.File(
	e.Name("resume"),
	b.Normal,
	fa.Icon(fa.Solid, "upload"),
	"Normal file…",
)
ResultHTML
Example
Code
b.File(
	e.Name("resume"),
	b.Medium,
	fa.Icon(fa.Solid, "upload"),
	"Medium file…",
)
ResultHTML
Example
Code
b.File(
	e.Name("resume"),
	b.Large,
	fa.Icon(fa.Solid, "upload"),
	"Large file…",
)
ResultHTML
Example
Code
b.File(
	e.Name("resume"),
	b.Small,
	fa.Icon(fa.Solid, "upload"),
	"Small file…",
	b.FileName("Screen Shot 2017-07-29 at 15.54.25.png"),
)
ResultHTML
Example
Code
b.File(
	e.Name("resume"),
	b.Normal,
	fa.Icon(fa.Solid, "upload"),
	"Normal file…",
	b.FileName("Screen Shot 2017-07-29 at 15.54.25.png"),
)
ResultHTML
Example
Code
b.File(
	e.Name("resume"),
	b.Medium,
	fa.Icon(fa.Solid, "upload"),
	"Medium file…",
	b.FileName("Screen Shot 2017-07-29 at 15.54.25.png"),
)
ResultHTML
Example
Code
b.File(
	e.Name("resume"),
	b.Large,
	fa.Icon(fa.Solid, "upload"),
	"Large file…",
	b.FileName("Screen Shot 2017-07-29 at 15.54.25.png"),
)
ResultHTML
Example
Code
b.File(
	e.Name("resume"),
	b.Small,
	b.Boxed,
	fa.Icon(fa.Solid, "upload"),
	"Small file…",
)
ResultHTML
Example
Code
b.File(
	e.Name("resume"),
	b.Normal,
	b.Boxed,
	fa.Icon(fa.Solid, "upload"),
	"Normal file…",
)
ResultHTML
Example
Code
b.File(
	e.Name("resume"),
	b.Medium,
	b.Boxed,
	fa.Icon(fa.Solid, "upload"),
	"Medium file…",
)
ResultHTML
Example
Code
b.File(
	e.Name("resume"),
	b.Large,
	b.Boxed,
	fa.Icon(fa.Solid, "upload"),
	"Large file…",
)
ResultHTML
Example
Code
b.File(
	e.Name("resume"),
	b.Small,
	b.Boxed,
	fa.Icon(fa.Solid, "upload"),
	"Small file…",
	b.FileName("Screen Shot 2017-07-29 at 15.54.25.png"),
)
ResultHTML
Example
Code
b.File(
	e.Name("resume"),
	b.Normal,
	b.Boxed,
	fa.Icon(fa.Solid, "upload"),
	"Normal file…",
	b.FileName("Screen Shot 2017-07-29 at 15.54.25.png"),
)
ResultHTML
Example
Code
b.File(
	e.Name("resume"),
	b.Medium,
	b.Boxed,
	fa.Icon(fa.Solid, "upload"),
	"Medium file…",
	b.FileName("Screen Shot 2017-07-29 at 15.54.25.png"),
)
ResultHTML
Example
Code
b.File(
	e.Name("resume"),
	b.Large,
	b.Boxed,
	fa.Icon(fa.Solid, "upload"),
	"Large file…",
	b.FileName("Screen Shot 2017-07-29 at 15.54.25.png"),
)
ResultHTML

Alignment

Example
Code
b.File(
	e.Name("resume"),
	b.Centered,
	b.Boxed,
	b.Success,
	fa.Icon(fa.Solid, "upload"),
	"Centered file…",
	b.FileName("Screen Shot 2017-07-29 at 15.54.25.png"),
)
ResultHTML
Example
Code
b.File(
	e.Name("resume"),
	b.Right,
	b.Info,
	fa.Icon(fa.Solid, "upload"),
	"Right file…",
	b.FileName("Screen Shot 2017-07-29 at 15.54.25.png"),
)
ResultHTML

JavaScript

In order to automatically change the file name when the user has selected a file, use b.FileNameAutoUpdate with a placeholder:

Example
Code
b.File(
	e.Name("resume"),
	fa.Icon(fa.Solid, "upload"),
	"Choose a file…",
	b.FileNameAutoUpdate("No file uploaded"),
)
ResultHTML