bs

package module
v0.16.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2025 License: GPL-3.0 Imports: 3 Imported by: 19

README

Bootstrap UI for Golang Open in Gitpod

An extensive Golang library for declaratve building of Bootstrap components.

Its an extension of the HTML Builder package: https://github.com/dracory/hb

You can find different examples below.

Alerts

bs.Alert().Class("alert-info").HTML("Info text")

bs.Alert().Class("alert-danger").HTML("Danger text")

bs.Alert().Class("alert-success").HTML("Success text")

bs.Alert().Class("alert-warning").HTML("Warning text")

Breadcrumbs

breadcrumbsPath := []bs.Breadcrumb{
	{
		Name: "Home",
		URL:  "/users",
		Icon: icons.Icon("bi-house-fill", 16, 16, "gray").ToHTML(),
	},
	{
		Name: "Profile",
		Icon: icons.Icon("bi-person-circle", 16, 16, "gray").ToHTML(),
		URL:  "/users/profile",
	},
	{
		Name: "Update details",
		URL:  "/users/profile/update",
	},
}

breadcrumbs := bs.Breadcrumbs(breadcrumbsPath).Style("background:#e9ecef;border-radius:10px;padding:10px;margin-bottom:10px;")

Result

Cards

card := bs.Card().ID("CardPreview").AddChildren([]hb.TagInterface{
	bs.CardHeader().Child(hb.NewHeading5().HTML("Preview")),
	bs.CardBody().Child(preview),
})

Tabs

bs.NavTabs().Children([]hb.TagInterface{
	bs.NavItem().Children([]hb.TagInterface{
		bs.NavLink().Class("active").Children([]hb.TagInterface{
			hb.NewSpan().HTML("Overview"),
		}),
	}),
	bs.NavItem().Children([]hb.TagInterface{
		bs.NavLink().Children([]hb.TagInterface{
			hb.NewSpan().HTML("Statistics"),
		}),
	}),
	bs.NavItem().Children([]hb.TagInterface{
		bs.NavLink().Children([]hb.TagInterface{
			hb.NewSpan().HTML("Preview"),
		}),
	}),
}),

Pills

bs.NavPills().Children([]hb.TagInterface{
	bs.NavItem().Children([]hb.TagInterface{
		bs.NavLink().Class("active").Children([]hb.TagInterface{
			hb.NewSpan().HTML("Overview"),
		}),
	}),
	bs.NavItem().Children([]hb.TagInterface{
		bs.NavLink().Children([]hb.TagInterface{
			hb.NewSpan().HTML("Statistics"),
		}),
	}),
	bs.NavItem().Children([]hb.TagInterface{
		bs.NavLink().Children([]hb.TagInterface{
			hb.NewSpan().HTML("Preview"),
		}),
	}),
}),

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alert

func Alert() *hb.Tag
func Breadcrumbs(breadcrumbs []Breadcrumb) *hb.Tag

func Button

func Button() *hb.Tag
func ButtonLink() *hb.Tag

func Card

func Card() *hb.Tag

func CardBody

func CardBody() *hb.Tag

func CardFooter

func CardFooter() *hb.Tag

func CardHeader

func CardHeader() *hb.Tag

func CardImageTop

func CardImageTop(src string) *hb.Tag

func CardTitle

func CardTitle() *hb.Tag

func Column

func Column(width int) *hb.Tag

func Container

func Container() *hb.Tag

func FormCheck

func FormCheck() *hb.Tag

func FormCheckBox

func FormCheckBox() *hb.Tag

func FormCheckLabel

func FormCheckLabel() *hb.Tag

func FormCheckRadio

func FormCheckRadio() *hb.Tag

func FormGroup

func FormGroup() *hb.Tag

func FormInput

func FormInput() *hb.Tag

func FormInputPlaintext

func FormInputPlaintext() *hb.Tag

func FormLabel

func FormLabel(label string) *hb.Tag

func FormSelect

func FormSelect() *hb.Tag

func FormSelectOption

func FormSelectOption(optionKey string, optionName string) *hb.Tag

func FormText

func FormText(text string) *hb.Tag

func FormTextArea

func FormTextArea() *hb.Tag

func InputGroup

func InputGroup() *hb.Tag

func InputGroupText

func InputGroupText() *hb.Tag
func Modal() *hb.Tag

func ModalBody

func ModalBody() *hb.Tag

func ModalContent

func ModalContent() *hb.Tag

func ModalDialog

func ModalDialog() *hb.Tag

func ModalFooter

func ModalFooter() *hb.Tag

func ModalHeader

func ModalHeader() *hb.Tag
func Nav() *hb.Tag
func NavItem() *hb.Tag
func NavLink() *hb.Tag
func NavPills() *hb.Tag
func NavTabs() *hb.Tag

func Pagination

func Pagination(options PaginationOptions) string

Pagination generates a pagination component given the options.

The options are: - NumberItems: The total number of items that are being paginated. - CurrentPageNumber: The current page number that is being displayed. - PerPage: The number of items per page. - PagesToShow: The number of pages to show in the pagination component. - URL: The base URL of the pagination component. - FirstPageStartsAt: The page number at which the first page starts.

The pagination component will generate a list of page numbers from min to max, where min is the minimum page number that should be displayed, and max is the maximum page number that should be displayed. The page numbers will be hyperlinked to the URL with the page number appended to the end. The page numbers will be displayed in a <nav> element with a <ul> element containing the page numbers. If the previous page number is greater than or equal to the first page starts at, then a previous page link will be displayed. If the next page number is less than the maximum page number, then a next page link will be displayed. The previous and next page links will be displayed in <li> elements with the class "page-item". The page numbers will be displayed in <li> elements with the class "page-item" and the class "active" if the page number matches the current page number.

The function will return an empty string if the maximum page number is less than 2.

Example:

options := PaginationOptions{
	NumberItems: 10,
	CurrentPageNumber: 2,
	PerPage: 5,
	PagesToShow: 5,
	URL: "/users/profile/",
	FirstPageStartsAt: 1,
}

pagination := Pagination(options)

func Row

func Row() *hb.Tag

func TabContent

func TabContent() *hb.Tag

func TabPane

func TabPane() *hb.Tag

Types

type Breadcrumb struct {
	URL   string
	Name  string
	Class string
	Icon  string
}

type PaginationOptions

type PaginationOptions struct {
	NumberItems       int
	CurrentPageNumber int
	PerPage           int
	PagesToShow       int
	URL               string
	FirstPageStartsAt int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL