ReGui
  • Introduction
  • Getting Started
    • Installing
    • Creating windows
  • Plugins
    • Custom elements
    • Custom flags
    • Custom themes
  • Examples
    • Demo window
    • Example scripts
  • Methods
  • ReGui functions
  • Canvas functions
  • Configuration saving
  • Elements
    • :Label
    • :Error
    • Code Editor
    • :Button
    • :SmallButton
    • :RadioButton
    • :Image
    • :VideoPlayer
    • :Checkbox
    • :Radiobox
    • :Viewport
    • :Console
    • :Region
    • :List
    • :CollapsingHeader
    • :TreeNode
    • :Separator
    • :Indent
    • :BulletText
    • :Bullet
    • :Row
    • :SliderInt
    • :SliderFloat
    • :SliderEnum
    • :SliderColor3
    • :SliderCFrame
    • :SliderProgress
    • :DragInt
    • :DragFloat
    • :DragColor3
    • :DragCFrame
    • :InputText
    • :InputTextMultiline
    • :InputInt
    • :InputColor3
    • :InputCFrame
    • :ProgressBar
    • :Combo
    • :Keybind
    • :PlotHistogram
    • :Table
    • :TabSelector
    • :Window
    • :TabsWindow
    • :PopupModal
Powered by GitBook
On this page
  • DefineElement
  • Basic TextLabel example:
  • Using other elements as a base:
  1. Plugins

Custom elements

DefineElement

-- This will be defined in the Elements class accessible by a Canvas
-- Or by ReGui.Elements:ElementName() but this method will not have theming
ReGui:DefineElement("ElementName", {
	-- These are the base values for the Config
	Base = {
		RichText = true,
		TextWrapped = true
	},
	--(OPTIONAL) This is the coloring infomation the theme system will use
	ColorData = {
		["ColorStyle Name"] = {
			TextColor3 = "ErrorText",
			FontFace = "TextFont",
		},
	},
	--(OPTIONAL) These values will be set in the base theme
	ThemeTags = {
		["ThemeTag"] = Color3.fromRGB(255, 69, 69),
		["CoolFont"] = Font.fromName("Ubuntu"),
	},
	--[[ This is the generation function for the element
	 self is the canvas class
	 Config is the configuration with overwrites to the Base config
	]]--
	Create = function(self, Config: Label)
		-- This MUST either return:
		  -- GuiObject
		  -- Class, GuiObject
	end,
})

Basic TextLabel example:

ReGui:DefineElement("PurpleText", { --// Method name
	Base = { --// Configuration base
		IsBigText = true
	},
	Create = function(self, Config)
		local IsBigText = Config.IsBigText -- true
		
		local Label = Instance.new("TextLabel")
		Label.TextSize = IsBigText and 30 or 14

		--// Must return: Instance or Table, Instance
		return Label
	end,
})

Using other elements as a base:

This is the code used for generating the ProgressBar element using the Slider element as a base

ReGui:DefineElement("ProgressBar", {
	Base = {
		Progress = true,
		ReadOnly = true,
		MinValue = 0,
		MaxValue = 100,
		Format = "% i%%"
	},
	Create = function(self, Config)
		function Config:SetPercentage(Value: number)
			Config:SetValue(Value)
		end

		return self:SliderBase(Config)
	end,
})
PreviousCreating windowsNextCustom flags

Last updated 2 months ago