Package: vblocks
VblocksZero-dependency Python library for declaratively building Slack Block Kit UI.Requirementsvblocksrequires Python >= 3.7.InstallationInstall vblocks with pippipinstallvblocksUsage/ExamplesThere are 4 different types of UI components: Blocks, Composition, Elements, and Views.Composition ExampleComposition elements are the simplest form of UI components. These objects can be used inside of block elements and certain message payloads.fromvblocksimportTexttext=Text(type="mrkdwn",text="A message *with some bold text* and _some italicized text_.",)text.json()Will generate the following{"type":"mrkdwn","text":"A message *with some bold text* and _some italicized text_."}Element ExampleElements can be used inside of SectionBlocks, ContextBlocks, InputBlocks, and ActionBlocks. These components are similar to standard HTML components, such as Buttons, Checkboxes, Date pickers, and more.fromvblocksimportButtonbutton=Button(text=Text("plain_text","Click Me"),action_id="button")button.json()Will generate the following{"type":"button","text":{"type":"plain_text","text":"Click Me"},"action_id":"button"}Block ExampleBlocks are components which can be combined to create layouts, with interactive components. These range from ActionBlocks, ContextBlocks, etc.action=ActionBlock(block_id="actions1",elements=[StaticSelectMenu(placeholder=Text(type="plain_text",text="Which witch is the witchiest witch?"),action_id="select_2",options=[Option(text=Text(type="plain_text",text="Matilda"),value="matilda",),Option(text=Text(type="plain_text",text="Glinda"),value="glinda",),Option(text=Text(type="plain_text",text="Granny Weatherwax"),value="grannyWeatherwax",),Option(text=Text(type="plain_text",text="Hermione"),value="hermione",),],),Button(text=Text(type="plain_text",text="Cancel"),action_id="button_1",value="cancel",),],)action.json()Will generate the following{"type":"actions","block_id":"actions1","elements":[{"type":"static_select","placeholder":{"type":"plain_text","text":"Which witch is the witchiest witch?"},"action_id":"select_2","options":[{"text":{"type":"plain_text","text":"Matilda"},"value":"matilda"},{"text":{"type":"plain_text","text":"Glinda"},"value":"glinda"},{"text":{"type":"plain_text","text":"Granny Weatherwax"},"value":"grannyWeatherwax"},{"text":{"type":"plain_text","text":"Hermione"},"value":"hermione"}]},{"type":"button","text":{"type":"plain_text","text":"Cancel"},"value":"cancel","action_id":"button_1"}]}View ExampleViews are visual areas within Modals, Home tabs, and Messages.fromvblocksimportModal,Text,Section,Button,Inputmodal=Modal(title=Text(type="plain_text",text="Modal title"),blocks=[Section(block_id="section1",text=Text(type="mrkdwn",text="It's Block Kit...but _in a modal_",),accessory=Button(text=Text(type="plain_text",text="Click me"),action_id="button_abc",value="Button value",style="danger",),),Input(label=Text(type="plain_text",text="Input label"),element=PlainTextInput(action_id="input1",placeholder=Text(type="plain_text",text="Type in here"),multiline=False,),optional=False,),],close=Text(type="plain_text",text="Cancel"),submit=Text(type="plain_text",text="Save"),private_metadata="Shhhhhhhh",callback_id="view_identifier_12",)modal.json()Will generate the following{"type":"modal","title":{"type":"plain_text","text":"Modal title"},"blocks":[{"type":"section","text":{"type":"mrkdwn","text":"It's Block Kit...but _in a modal_"},"block_id":"section1","accessory":{"type":"button","text":{"type":"plain_text","text":"Click me"},"action_id":"button_abc","value":"Button value","style":"danger"}},{"type":"input","label":{"type":"plain_text","text":"Input label"},"element":{"type":"plain_text_input","action_id":"input1","placeholder":{"type":"plain_text","text":"Type in here"},"multiline":false},"optional":false}],"close":{"type":"plain_text","text":"Cancel"},"submit":{"type":"plain_text","text":"Save"},"private_metadata":"Shhhhhhhh","callback_id":"view_identifier_12"}Class ReferenceBelow is a list of supported Slack UI elements and their respectiveVblocks:NameTypeClassActionBlockActionBlock()ContextBlockContextBlock()DividerBlockDividerBlock()FileBlockFileBlock()HeaderBlockHeaderBlock()ImageBlockImageBlock()InputBlockInputBlock()SectionBlockSectionBlock()TextCompositionText()ConfirmationCompositionConfirmation()OptionCompositionOption()Option GroupCompositionOptionGroup()Dispatch Action ConfigurationCompositionDispatchAction()FilterCompositionFilter()ButtonElementButton()Checkbox GroupElementCheckboxGroup()Date PickerElementDatePicker()ImageElementImage()Multi Static SelectElementMultiStaticSelect()Multi External SelectElementMultiExternalSelect()Multi User SelectElementMultiUserSelect()Multi Conversation SelectElementMultiConversationSelect()Multi Channel SelectElementMultiChannelSelect()Overflow MenuElementOverflowMenu()Plain Text InputElementPlainTextInput()Radio Button GroupElementRadioButtonGroup()Static Select MenuElementStaticSelectMenu()External Select MenuElementExternalSelectMenu()User Select MenuElementUserSelectMenu()Conversation Select MenuElementConversationSelectMenu()Static Select MenuElementStaticSelectMenu()Channel Select MenuElementChannelSelectMenu()Time PickerElementTimePicker()